Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery and jqGrid - For ... Each Loop To Extract Data
    text
    copied!<p>Environment: <br>* jquery-2.0.0.js <br>* jqSuitePHP_4_4_4_0</p> <p>I have a grid populated with data; for every row in the grid I would like to extract only two of the columns, the same two columns for each row. I don't need the jgGrid ID of the row as I have my own which is one of the two fields I am after. The second field I want holds a select menu - I want the value as opposed to the text of the field.</p> <p>In my experimenting, the best I could come up with was capturing the entirety of each row and JSON encoding it to submit.</p> <pre><code>jQuery('#myGrid').jqGrid().jqGrid ( 'navButtonAdd', '#myPager', { ... onClickButton: function() { var grid = $('#myGrid'); var data = JSON.stringify(grid.jqGrid('getGridParam', 'data')); request = $.ajax({ url: 'process.php', type: 'post', data: data }); } } ); </code></pre> <p>The problem is I don't want to do that. So I'm stuck on how to for ... each to build my 'data' value that can be seen in the sample code in the AJAX POST. I want POST as 1=this&amp;2=that where the integers are my row IDs (the first field I want to capture) and 'this' and 'that' are the values of the select menus (the second field I want) and do away with the JSON.</p> <p>Thanks for your help.</p> <p>=== EDIT === <br>* Adding sample grid <br>* Highlighting the portion of code that is challenging me</p> <pre><code>+---------------------------------------------+ | Column 1 | * Column 2 | Column 3 | Column 4 | |----------|------------|----------|----------| | 1 | This | Other | Stuff | |----------|------------|----------|----------| | 2 | That | More | Stuff | +---------------------------------------------+ </code></pre> <p>*Column 2 is actually a select menu so rather than the text that appears to the user in the grid, I want the underlying value that they set. For conversation, we'll say 'This' = 100 and 'That' = 999. So from the sample above I want to be able to AJAX POST:</p> <p>1=100 <br>2=999</p> <p>My AJAX request...</p> <pre><code>request = $.ajax({ url: 'process.php', type: 'post', data: data }); </code></pre> <p>How do I get 1=100 and 2=999 into the variable 'data' to be used in the above AJAX request? I think I'm supposed to be using $.each() but not sure and even if that is correct I don't know what beyond that. I don't want Column 3 or 4.</p> <p>Thanks for your time and thought.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload