How do I capture a selection in a jqgrid for use in my wiki application?
This code allows you to select multiple rows on a grid. Once a selection is made, a submit button will redirect the user to a page with a URLPARAM selection that contains each of the selected web.topic names:
%GRID{
query="form.name~'*UserForm'"
web="%USERSWEB%"
form="System.UserForm"
filterbar="on"
id="grid"
multiselect="on"
gridComplete="initSelectButton"
pager="on"
}%
<form id="selectionform" action="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%">
<input type="submit" id="getselected" value="Submit"/>
</form>
%FORMAT{
"%URLPARAM{"selection" multiple="on" separator=","}%"
header="---++ Selected users$n"
format=" * [[$web.$topic][$formfield(FirstName) $formfield(LastName)]] - [[$formfield(OrganisationURL)][$formfield(OrganisationName)]]"
}%
%ADDTOZONE{
"script"
requires="JQUERYPLUGIN::GRID"
topic="%TOPIC%"
section="mySelect"
}%<verbatim class="foswikiHidden">
%STARTSECTION{"mySelect"}%<script>
function initSelectButton () {
jQuery("#getselected").click(function(){
var addTopic = function(index, value) {
jQuery('#selectionform').append('<input type="hidden" name="selection" value="' + value + '"/>');
};
var selr = jQuery('#grid').jqGrid('getGridParam','selarrrow');
jQuery.each( selr, addTopic )});
}</script>%ENDSECTION{"mySelect"}%
</verbatim>