EasyUI Forum
May 17, 2024, 06:18:12 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 filter textboxes - set prompt  (Read 6323 times)
gordis gmbh
Full Member
***
Posts: 103


View Profile Email
« on: June 20, 2016, 07:57:05 AM »

How can I set a default prompt to all the filter textboxes of all filter-enabled datagrids?

The prompt may be for e.g. 'enter filter text here...'

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 20, 2016, 06:13:49 PM »

Just set the 'prompt' option for the textbox.

Code:
dg.datagrid('enableFilter', [{
    field:'attr1',
    type:'textbox',
    options:{
        prompt:'enter filter text here...'
    }
}]);
Logged
gordis gmbh
Full Member
***
Posts: 103


View Profile Email
« Reply #2 on: June 23, 2016, 02:33:01 AM »

To enable filter as per your suggesstion one needs field name.

We enable filter for all datagrids in one central location as follows:
Code:
	if (specialFilters.length > 0) {
$('#'+datagridSelector).datagrid('enableFilter', specialFilters); // enable filter with given special filters
} else {
$('#'+datagridSelector).datagrid('enableFilter'); // enable filter with type textbox
}

As you can see, there is no datagrid-field information given for textbox-based filters. Special filters are combobox or datebox or numberbox filters which contain field-name and corresponding options...

For time being I found a workaround by adding the following line directly in source code file "datagrid-filter.js":
Code:
input.attr('placeHolder', 'enter filter text here ...');

This works but I am looking for a possibility to do the same - by default - for all filter-enabled datagrids without modifying the source code.

Perhaps by extending the filter - plugin in my code. But the problem is, setting the prompt after the textbox is initialised effects the textbox size! Any ideas in this direction are welcome ...

« Last Edit: June 23, 2016, 02:35:25 AM by gordis gmbh » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: June 23, 2016, 07:58:56 AM »

You can override the 'defaultFilterType' and 'defaultFilterOptions' to set properties for all un-specialed fields.
Code:
var dg = $('#dg').datagrid({
    defaultFilterType: 'textbox',
    defaultFilterOptions: $.extend({},$.fn.datagrid.defaults.defaultFilterOptions,{
        prompt:'enter filter text here...'
    })
});
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!