SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: JQGrid Filter

  1. #1
    SitePoint Zealot ajaxdinesh's Avatar
    Join Date
    Apr 2009
    Location
    India
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question JQGrid Filter

    Hi Guys,

    I have loaded all values in the table from array using JQgrid. I added one filter toolbar in the header which i have defined the selectbox and populated the values are few condition operator(Like >10, <10 etc... ) for tax column. My question is how can i fetch the value from the selectbox and apply the filter according the condition. Please help me.

    Regards,
    Dinesh
    Cheers,
    Dinesh

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ajaxdinesh View Post
    Hi Guys,

    I have loaded all values in the table from array using JQgrid. I added one filter toolbar in the header which i have defined the selectbox and populated the values are few condition operator(Like >10, <10 etc... ) for tax column. My question is how can i fetch the value from the selectbox and apply the filter according the condition. Please help me.

    Regards,
    Dinesh
    About the best example of that is in the Live Data Manipulation section from their documentation page at http://trirand.com/blog/jqgrid/jqgrid.html
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot ajaxdinesh's Avatar
    Join Date
    Apr 2009
    Location
    India
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by paul_wilkins View Post
    About the best example of that is in the Live Data Manipulation section from their documentation page at http://trirand.com/blog/jqgrid/jqgrid.html
    thanks for your reply, In the same functionality i have placed that selectbox filter under taxcolumn in the header layer. i don't want popup filter toolbar inside table . I hope you understand my requirement.

    Eg:
    Code HTML4Strict:
    <select>
    <option value='10'>&gt10</option>
    <option value='20'>&gt20</option>
    <option value='10'>&lt10</option>
    </select>

    My Script Code:
    Code JavaScript:
    jQuery(document).ready(function () {
     
    	var op = ":All;10:>10;20:>20;10: < 10";
    	var arr = ['ge','le'];
    	var sym;
     
    	var mygrid = jQuery("#colch").jqGrid({
    		data: mydata,
    		datatype: "local",
    		colNames:['Inv No','Date', 'Client Has Long Title', 'Amount','Tax','Total','Notes'],
    		colModel:[
    			{name:'id',index:'id', width:60, sorttype:"int"},
    			{name:'invdate',index:'invdate', width:90, sorttype:"date"},
    			{name:'name',index:'name', width:100},
    			{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
    			{name:'tax',index:'tax', width:80, align:"right",sorttype:"float",search:true, stype:'select', searchoptions:{
    				value: op,
    				sopt:["\'"+sym+"\'"],
    				dataEvents :[
    					{type: 'change', fn: function(e) {
    						var thisval = $(this).find('option:selected').text();
    						if(thisval=='<10'){
    							sym= arr[1];
    						}
    						else{
    							sym = arr[0];
    						}
    						//alert(sym);
    					}
    				}]
     
    			},	
    			editrules: { required: true}
    			},		
    			{name:'total',index:'total', width:80,align:"right",sorttype:"float"},		
    			{name:'note',index:'note', width:150, sortable:false, hidden:true}		
    		],
    		rowNum:10,
    		width:800,
    		height:350,
    		rowList:[10,20,30,40],
    		pager: '#pcolch',
    		sortname: 'invdate',
    		shrinkToFit :true,
    		viewrecords: true,
    		sortorder: "tax",
    		caption:"Column Chooser Example"
    	});

    The value is not assigned in the sopt when i change the value in selectbox. Can you please check what error in that code?
    Cheers,
    Dinesh


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •