Setting up jqGrid is not terribly difficult, but customizing it can be somewhat more difficult. Take this paragraph from the wiki article on search:
There are four approaches:
* a toolbar searching
* a custom searching
* a single field searching
* a more complex approach involving many fields and conditions – advanced searchingThese approaches use common options from jqGrid and so can be called only on an already-constructed grid. Every search method requires that some additional module should be included into the package. Also refer to Download or in every specific module on what should be included
But there are no links to article on the different search modules and the download page does not include any more details.
What to do? Here’s a working search function partially provided by Trirand support:
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript">
function searchContact(letter, field, oper)
{
if(!oper) oper = 'bw';
// build the filter
var filter = {"groupOp":"OR","rules":[{"field":"FirstName","op":oper,"data":letter},{"field":"Lastname","op":oper,"data":letter},{"field":"Phone","op":oper,"data":letter}] };
$("#Contactdatatable").jqGrid('setGridParam',{search:true, postData:{filters:filter} } );
$("#Contactdatatable").trigger("reloadGrid");
return false;
}
</script>
Here is what a modified version looks like in my Salesforce component:
function search{!uid}(arg, field, oper)
{
if(!oper) oper = 'bw';
if(field)
$enhanced{!uid}.jqGrid('setGridParam',{search:true, postData:{searchOper:oper,searchField:field, searchString:arg}});
else {
var filter = {"groupOp":"OR","rules":{!colRulesJson} };
$enhanced{!uid}.jqGrid('setGridParam',{search:true, postData:{filters:filter} });
}
$enhanced{!uid}.trigger("reloadGrid");
return false;
}
An editable, searchable implementation for Salesforce has just been finished as part of something I am working on for the Salesforce Foundation:
Soon to be generally available.


6 comments
Comments feed for this article
August 12, 2010 at 9:50 am
Jeff
Can’t wait to see a working demo of this!
August 15, 2010 at 3:17 pm
rubixtious
This looks very interesting. I recently used Jeff’s dynamic search code but this looks even better with pagination and alphabetical quick search.
July 13, 2011 at 7:14 am
varunchaddha
looks so cool …. when is this being made available
?
July 13, 2011 at 6:17 pm
d3developer
Actually, all the code is on Github: https://github.com/fractastical/jqGrid-Salesforce-integration/tree/f8f5ea0eb3f1d2b447e93129496690379defea9f
There is also a unmanaged package that was circulated among the non-profit community some time ago.
December 29, 2011 at 3:07 pm
Ugesh
Can you publish your unmanaged code in your site.
March 5, 2012 at 10:10 pm
Joel Dietz (@fractastical)
A somewhat out of date version is available on github.