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>

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Extension, Frontend or Javascript or CSS
Topic Summary Demonstrates usage of JQGridPlugin's multiselect and gridComplete parameters
Extension JQGridPlugin
Interested Parties
Related Topics JQGridPlugin
Topic revision: r3 - 27 Dec 2011, ArthurClemens - This page was cached on 16 Dec 2017 - 20:03.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License