EasyUI Forum
May 15, 2024, 09:29:46 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: Dynamic data option in filter datagrid  (Read 22399 times)
acreonte82
Jr. Member
**
Posts: 85



View Profile
« on: May 09, 2014, 07:09:25 AM »

Hello to all,
when we define the filter in datagrid we also have to define the value will be present in a combobox filter
Code:
$('#laboratory_result').datagrid({remoteFilter:true}); 

$('#laboratory_result').datagrid('enableFilter',[
{
field:'type_of_result',
               type:'combobox',              
               options:{
                   panelHeight:'auto',                  
                   data:[ {value:'',text:'All'},
                    {value:'Check positive control - Matching passed',text:'Check positive control - Matching passed'},
                    {value:'Check positive control - Matching failed',text:'Check positive control - Matching failed'},
                    {value:'Get genotype data',text:'Get genotype data'},
                    {value:'Sample ID not found',text:'Sample ID not found'},
                    {value:'UNDETERMINED/OMITTED',text:'UNDETERMINED/OMITTED'}
                    ],
                 
                   onChange:function(value){
                       if (value == ''){
                           $('#laboratory_result').datagrid('removeFilterRule');                            
                           
                       } else {
                           $('#laboratory_result').datagrid('addFilterRule', {
                               field: 'type_of_result',
                               op: 'equal',
                               value: value
                           });                          
                       }
                        $('#laboratory_result').datagrid('doFilter');
                   }
               }
           },
           {
               field:'sample_number',
               type:'text',
               options:{precision:1},
               op:['equal','beginwith']
           },
           {
               field:'genotype_old',
               type:'text',
               options:{precision:1},
               op:['equal','beginwith']
           },
           {
               field:'genotype',
               type:'text',
               options:{precision:1},
               op:['equal','beginwith']
           }

       ]);
When we set the values for a combobox filter the problem is how to implement a function that retrive all element for the combobox
At the moment I created a php script that return to me a json string with the grouped values
The question is easy: how can I integrate all?

who can help me?
« Last Edit: May 09, 2014, 07:11:57 AM by acreonte82 » Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #1 on: May 12, 2014, 12:46:08 AM »

stworthy can u help me?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: May 12, 2014, 01:31:57 AM »

To let combobox retrieve data from remote server, simply set the specified 'url' property.
Code:
$('#laboratory_result').datagrid('enableFilter',[
{
field:'type_of_result',
type:'combobox',              
options:{
panelHeight:'auto',                    
url: ...,  // specify the url to retrieve data from remote server
onChange:function(value){
//...
}
}
},
...
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #3 on: May 13, 2014, 12:20:00 AM »

Ok I need a vacation....

A last question: if I want to reload the data in the combobox after I reset the filter (selecting the option 'All')?

This is to update the possibile value of filter..

Thanks
« Last Edit: May 13, 2014, 12:25:05 AM by acreonte82 » Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #4 on: May 14, 2014, 06:54:37 AM »

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


View Profile Email
« Reply #5 on: May 14, 2014, 07:39:58 AM »

Don't understand your question clearly. Maybe you need to explain it in more detail.
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #6 on: May 16, 2014, 12:29:35 AM »

The scenario, of my case , is this:
- I have a datagrid with some medical results and in this datagrid I defined a personal comands to manage the data (update/delete/standby);
- each columns have a filter and one have combobox filter . The grouped values, of this combobox, are loaded from a php script (a dynamic value)
 

For example: if I show the medical result , selected from a value defined in the combobox , and then I deleted all results , I want to reload the filter values of the combobox. So the system show me the remaining possible values of filter loaded from a php script.

The question is: how I can force the reload of the combobox filter?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: May 16, 2014, 02:10:59 AM »

To reload the data of combobox filter component, call 'getFilterComponent' method to get this object and then call 'reload' method on it.
Code:
var cc = $('#dg').datagrid('getFilterComponent', 'type_of_result');
cc.combobox('reload');
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #8 on: May 16, 2014, 02:50:37 AM »

Thanks!
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!