EasyUI Forum
April 27, 2024, 01:57:30 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid search field clear button  (Read 5029 times)
rezzonico
Full Member
***
Posts: 182


View Profile
« on: November 27, 2017, 02:46:38 AM »

Hi all,

I have a datagrid with (suppose) only one column (Assetnum).
After the datagrid is created I call enableFilter with the following options:

         $('#dg').datagrid('enableFilter', [
            {
               field: 'Assetnum',
               type: 'combotree',
               options: {
                  editable: true,
                  valueField: 'Assetnum',
                  textField: 'Assetnum',
                  url: 'prog.cgi',
                  onChange: function(value) {
                     if (value == '') {
                        $('#dg').datagrid('removeFilterRule', 'Assetnum');
                     }
                     else {
                        $('#dg').datagrid('addFilterRule', {
                           field: 'Assetnum',
                           value: value
                        });
                     }
                     $('#dg').datagrid('doFilter');
                  }
               }
            }

After that I add a clear-icon near the search field:

         $('#_easyui_textbox_input1').textbox({
            icons:[{
               iconCls: 'icon-clear',
               handler: function(e) {
                  $('#dg').datagrid('removeFilterRule', 'Assetnum');
               }
            }]
         });

The problem is that this only works if the option editable is set to true (see red line above).
If editable is false, also 'icon-clear' is disabled and the handler function (see green line above) is not executed.

My question is this:
Is it possible to disable the search field "Assetnum" but not the handler function ?


Thanks for any help
Miche
« Last Edit: November 27, 2017, 06:39:33 AM by rezzonico » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: November 27, 2017, 06:46:27 PM »

The code below attaches a 'clear' icon to the editor. You can click the 'clear' button although the 'editable' is set to false.
Code:
editable: false,
valueField: 'Assetnum',
textField: 'Assetnum',
url: 'prog.cgi',
icons:[{
    iconCls:'icon-clear',
    handler: function(e){
        //...
    }
}],
onChange: function(value) {
//...
}
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #2 on: November 28, 2017, 03:35:47 AM »

It works !

Thanks a lot.
Miche
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!