如何筛选ExtJs GridPanel / ExtJs商店?(How to filter ExtJs GridPanel/ExtJs Store?)
我是ExtJs的新手。 我有一个与
data store
绑定的GridPanel
。 我有一个checkboxgroup
,它包含GridPanel
行的可能值。 我想用checkboxgroup
值过滤GridPanel
。这里是代码 -
Store1 = new Ext.data.JsonStore({ url: 'CustomerProfiles/GetDetails', root: 'rows', fields:['Name','Id'] }); DetailedResults = { xtype: 'grid', autoHeight: true, autoWidth: true, autoScroll: true, border: false, trackMouseOver: false, frame: true, store: Store1, columns: [ { header: 'Name', dataIndex: 'Name', width: 90 }, { header: 'Id', dataIndex: 'Id', width: 50 } ] }; Leftpanel = new Ext.Panel({ id: 'Leftpanel', frame: true, width: 175, items: [ { xtype: 'label' }, { xtype: 'checkboxgroup', columns: 1, vertical: true, items: [{ boxLabel: 'ALL', name: 'chkName', inputValue: 'all' }, { boxLabel: 'N1', name: 'chkName', inputValue: 'N1' }, { boxLabel: 'N2', name: 'chkName', inputValue: 'N2' }, { boxLabel: 'N3', name: 'chkName', inputValue: 'N3' }], listeners: { change: { fn: function () { Store1.clearFilter(); var selectedValue = this.getValue(); for (var i = 0; i < selectedValue.length; i++) { Store1.filter('Name', selectedValue[i].inputValue); } } } } } ]});
我哪里出错了?
PS:我正在使用3.4版本
I'm new to ExtJs. I have a
GridPanel
which is binded with adata store
. I have acheckboxgroup
, which containts the possible values of theGridPanel
row. I want to filter theGridPanel
with thecheckboxgroup
values.Here is the code -
Store1 = new Ext.data.JsonStore({ url: 'CustomerProfiles/GetDetails', root: 'rows', fields:['Name','Id'] }); DetailedResults = { xtype: 'grid', autoHeight: true, autoWidth: true, autoScroll: true, border: false, trackMouseOver: false, frame: true, store: Store1, columns: [ { header: 'Name', dataIndex: 'Name', width: 90 }, { header: 'Id', dataIndex: 'Id', width: 50 } ] }; Leftpanel = new Ext.Panel({ id: 'Leftpanel', frame: true, width: 175, items: [ { xtype: 'label' }, { xtype: 'checkboxgroup', columns: 1, vertical: true, items: [{ boxLabel: 'ALL', name: 'chkName', inputValue: 'all' }, { boxLabel: 'N1', name: 'chkName', inputValue: 'N1' }, { boxLabel: 'N2', name: 'chkName', inputValue: 'N2' }, { boxLabel: 'N3', name: 'chkName', inputValue: 'N3' }], listeners: { change: { fn: function () { Store1.clearFilter(); var selectedValue = this.getValue(); for (var i = 0; i < selectedValue.length; i++) { Store1.filter('Name', selectedValue[i].inputValue); } } } } } ]});
Where I went wrong?
PS: I am using 3.4 version
原文:https://stackoverflow.com/questions/20794617
更新时间:2023-12-16 19:12
最满意答案
您可以使用DatePickerDialog为我发布示例代码
static final int DATE_DIALOG_ID = 999; DatePickerDialog.OnDateSetListener date; date = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub myCalendar.set(Calendar.YEAR, year); myCalendar.set(Calendar.MONTH, monthOfYear); myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); updateLabel(val); } }; depart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub showDialog(DATE_DIALOG_ID); val = 1; } }); protected Dialog onCreateDialog(int id) { final Calendar now = Calendar.getInstance(); switch (id) { case DATE_DIALOG_ID: // set date picker as current date DatePickerDialog _date = new DatePickerDialog(this, date, myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)) { @Override public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { if (year - now.get(Calendar.YEAR) > 1) { view.updateDate(year - 1, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year - now.get(Calendar.YEAR) == 1 && monthOfYear > now.get(Calendar.MONTH)) { view.updateDate(year, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year - now.get(Calendar.YEAR) == 1 && monthOfYear == now.get(Calendar.MONTH) && dayOfMonth > now.get(Calendar.DAY_OF_MONTH)) { view.updateDate(year, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year < now.get(Calendar.YEAR)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); if (monthOfYear < now.get(Calendar.MONTH) && year == now.get(Calendar.YEAR)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); if (dayOfMonth < now.get(Calendar.DAY_OF_MONTH) && year == now.get(Calendar.YEAR) && monthOfYear == now.get(Calendar.MONTH)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } }; return _date; } return null; }
设置日期:
private void updateLabel(int val) { String myFormat = "dd/MM/yy"; // In which you need put here SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US); Log.d("Date value ", "===" + sdf.format(myCalendar.getTime())); depart.setText(sdf.format(myCalendar.getTime())); }
You can use DatePickerDialog for this i am posting a sample code for you
static final int DATE_DIALOG_ID = 999; DatePickerDialog.OnDateSetListener date; date = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub myCalendar.set(Calendar.YEAR, year); myCalendar.set(Calendar.MONTH, monthOfYear); myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); updateLabel(val); } }; depart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub showDialog(DATE_DIALOG_ID); val = 1; } }); protected Dialog onCreateDialog(int id) { final Calendar now = Calendar.getInstance(); switch (id) { case DATE_DIALOG_ID: // set date picker as current date DatePickerDialog _date = new DatePickerDialog(this, date, myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)) { @Override public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { if (year - now.get(Calendar.YEAR) > 1) { view.updateDate(year - 1, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year - now.get(Calendar.YEAR) == 1 && monthOfYear > now.get(Calendar.MONTH)) { view.updateDate(year, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year - now.get(Calendar.YEAR) == 1 && monthOfYear == now.get(Calendar.MONTH) && dayOfMonth > now.get(Calendar.DAY_OF_MONTH)) { view.updateDate(year, myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } if (year < now.get(Calendar.YEAR)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); if (monthOfYear < now.get(Calendar.MONTH) && year == now.get(Calendar.YEAR)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); if (dayOfMonth < now.get(Calendar.DAY_OF_MONTH) && year == now.get(Calendar.YEAR) && monthOfYear == now.get(Calendar.MONTH)) view.updateDate(myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)); } }; return _date; } return null; }
To set the Date :
private void updateLabel(int val) { String myFormat = "dd/MM/yy"; // In which you need put here SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US); Log.d("Date value ", "===" + sdf.format(myCalendar.getTime())); depart.setText(sdf.format(myCalendar.getTime())); }
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
这不会出于一个非常简单的原因:MyActivity()永远不会被调用。 Android会调用你的Activity的onCreate()方法,但其他的方法调用必须由你来完成。 因为你永远不会称你为MyActivity()方法,所以该按钮永远不会被赋予onClickListener(),并且声音从不播放。 请尝试使用以下代码: public class MainActivity extends Activity { private static final String TAG = "MyActivi ...
-
public void OnAdd(View v) { v1 = Double.parseDouble(total); total = ""; Button button = (Button) v; String str = button.getText().toString(); sign = str; EditText edit = (EditText) findViewById(R.id.editText); ** edit.setText(""); } ...
-
是否可以让asp:calender显示数据库中的日期?(Is it possible to have asp:calender show a date from the database?)[2022-12-18]
最后想出了如何在数据库显示中设置日期在日历中。 这是代码: Dim strConn As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\scrummingit2.mdf;Integrated Security=True;User Instance=True" Dim sql As String = "SELECT [Year], [Autumn_Start], [Autumn_End], ... -
在js方法中只需要做类似的事情 var today = new Date(); var twentyDays = new Date(); twentyDays.setDate(today.getDate()+20); if (selectedDate.getDateOnly() <= todayDate.getDateOnly()) { alert('Date Cannot be in the past or current date'); sender._textbox.set_Va ...
-
如何通过单击一个简单的按钮在Android中显示日历(How to Show a Calender in android by clicking a simple button)[2022-05-19]
您可以使用DatePickerDialog为我发布示例代码 static final int DATE_DIALOG_ID = 999; DatePickerDialog.OnDateSetListener date; date = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthO ... -
如何通过单击android中的自定义按钮打开搜索?(How to open the search by clicking a custom button in android? [closed])[2021-11-23]
您可以将Intent类与Web搜索操作一起使用: private void onSearchRequested() { Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, "your search query"); startActivity(intent); } You can use the Intent class with web sear ... -
调用方法SelectVate on textview或button或editext click private void SelectDate() { final Calendar c = Calendar.getInstance(); year = c.get(Calendar.YEAR); month = c.get(Calendar.MONTH); day = c.get(Calendar.DAY_OF_MONTH); showDialog(DATE_P ...
-
无需重新发明轮子。 看一下这个: CodeProject上可以为Nulllable的DateTimePicker 和这个: 又一个可以为空的DateTimePicker控件 i found a way myself.. =).. the DateTimePicker displays the calender icon button when the control is wider than the text displayed.. when the button starts to clip the t ...