In my application, I store hidden values in each of the 10 rows of my jqgrid. These hidden values are responses from the result of my application being executed.
So for example, I have two hidden JqGrid columns called "responseId", and "responseMsg" in my jqgrid called summaryGrid.
I want to loop through each of the 10 rows of my #summaryGrid jQgrid and save the values of "responseId" and "responseMsg" (only if they aren't null) in an array of 10 elements, each corresponding to the result of each row of the jqGrid. Next, I want to display the data in the array as an alert.
So far, I've just been able to loop through the JqGrid and load "responseId" only. I'm having difficulty loading the second value "responseMsg" into the array, and then displaying those in an alert when clicking a link.
Here's what I have so far. It's just loading a one dimensional array. I'm having difficulty loading the 2nd dimension.
function gridResponses(){
var responseList = new Array();
for(var i = 0; i < 10; i++){
var responseGrid = $("#summaryGrid"),
responseId = responseGrid.jqGrid('getCell',i,'responseId'),
if (responseList[i] != false && responseList[i] != null){
responseList[i] = responseId;
}
}
}
When I click a link to execute this function, I want an alert to show something like this:
Response ID Response Message
00001 Success
00002 Success
00003 Failure
00004 Success
In this case, only 4 of 10 rows had responses stored, so I only need to display the 4 pairs.
this is how "second dimension" would work, you simply assign an array to the key of an array. responseId could also be an array with many nested arrays, this doesnt matter.
responseList[i]=[responseId,responseMsg];
to give it more readable syntax i would rather use Objects, for easier access, like
responseList[i] = {'responseId':responseId,'responseMsg':responseMsg}
so you dont have to code freaky stuff like responseList[i][1] but responseList[i].responseMsg
Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.