homepage Welcome to WebmasterWorld Guest from 54.161.246.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Help setting default column and operator in jqGrid search dialog.
nelsonm

5+ Year Member



 
Msg#: 4537251 posted 8:30 pm on Jan 18, 2013 (gmt 0)

Hi all,

This is for all you jqGrid users. I appended a new button to the nav bar to open an alternate search dialog using:

function setFilterByCustomer(grid){
$('#'+grid+'_toppager_left').append("<input id='FilterByCustomer' type='button' value='Filter By Customer' style='height:22px; margin-left:5px;'/>");
$('#'+grid+'_toppager_left input#FilterByCustomer').click( function(){

$(grid).jqGrid ('searchGrid', {multipleSearch:true});

});
}

All i want to do is have the search dialog pop up with a specific column and operator pre-selected. However, there does not appear to be any option with the searchGrid method that allow for defining a specific column or operator as selected.

Is there another way to select a specific column and operator in the search dialog before or after it opens?

thanks

 

nelsonm

5+ Year Member



 
Msg#: 4537251 posted 7:47 am on Jan 19, 2013 (gmt 0)

Ok, i figured it out.

If you need to initially preselect and display a specific column, operator and/or a value in a search dialog...

1. For the default search dialog simply add the grid option:
postData:{'filters':{'groupOp':'AND/OR','rules':[{'field':'column','op':'operator','data':''}]}},

to the grid definition.

2. For additional search buttons in the nav bar, use:
function setFilterByCustomer(grid){
$('#'+grid+'_toppager_left').append("<input id='FilterByCustomer' type='button' value='Filter By Customer' style='height:22px; margin-left:5px;'/>");
$('#'+grid+'_toppager_left input#FilterByCustomer').click( function(){
$(grid).jqGrid('setGridParam',{postData:{'filters':{'groupOp':'AND/OR','rules':[{'field':'column','op':'operator','data':''}]}}});
$(grid).jqGrid ('searchGrid', {options})
});
}


3. Substitute the bold parts with the appropriate info.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved