EasyUI Forum
September 16, 2025, 07:59:04 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: generic datagrid filters in the toolbar  (Read 13143 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: February 26, 2013, 04:05:12 AM »

I am trying to avoid having to write custom code for each occurrence of a datagrid, and instead create a generic datagrid with filter criteria in the toolbar defined as either a text box or a combo box.

Code:
<table data-options="">
    <div class="dgtoolbar">
        <label>Year:</label><input name="year">
        <label>Type:</label><input name="type" classname="easyui-combobox" data-options="data:[{txt:xxx,val:yyy},{txt:aaa,val:bbb}]">
    </div>
</table>

So whenever the user selects a combo item, or changes the text in one of the fields contained within the datagrid's toolbar, I need to update the parameters of the dataagrid with thee values and reload it.

But I don't want to have to create individual functions for each occurrence of a datagrid and associated filter, as it is basically repeating the same code over and over again, the only things that change are the filter input names and the datagrid object.

How can I achieve this ?? 


Logged

-- Licensed User --
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #1 on: February 26, 2013, 04:26:04 AM »

Hi,

I have similar situation, but I solve it in two ways:

1) If I need to have list of treeGrid objects at the same time on one page but in different Tabs I put unique ID for each object when I load Tab content using PHP script.
In this case HTML/JS code comes with correct IDs every time

2) Create generic function and pass object name (tree(data)Gird id) and all other parameters into it.
ex. $('#'+objName).treeGrid('action', 'parameter='+parameters);
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: February 26, 2013, 04:58:03 AM »

Hi;

Thanks so much for helping but I am really trying to avoid using IDs completely, as to keep track of all of the IDs for all of the elements on a page is a huge headache, it's OK if you have say less than a dozen, but with forms and data being pulled from multiple database tables it's a real headache to ensure that all IDs are unique within the application.

I am also trying to define as much as possible through html and as little as possible with custom javascript.  I guess what I am looking for is a datagrid "filter bar" such that whenever any element within the datagrid's filter bar changes, the associated datagrid is reloaded with the values of the input elements within the datagrid's filter bar.




Logged

-- Licensed User --
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #3 on: February 26, 2013, 06:27:33 AM »

it's a real headache to ensure that all IDs are unique within the application.

For point #1 described by me above I use timestamp in the end of each object ID. So, ID is unique every time.
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!