Forum
00:50
06/06/2014
Good evening, everyone. My team has run into two problems related to having more than one jqGrid on a page.
The first problem is that while the grids themselves uniquely identify their components, the search toolbar does not. Suppose you have two simple grids for displaying lists of sales orders and user notifications respectively:
colmodel = [{label: "Sales Order ID", name: "SoId", index: "SoId", sortable: true, key: true}, Â Â Â Â Â Â Â Â Â Â Â {label: "Sold By", name: "EmpNo", index: "EmpNo", sortable: true}, Â Â Â Â Â Â Â Â Â Â Â {label: "Bought By", name: "CustNo", index: "CustNo", sortable: true}]
colmodel = [{label: "Notification ID", name: "NoteId", index: "NoteId", sortable: true, key: true}, Â Â Â Â Â Â Â Â Â Â Â {label: "User", name: "EmpNo", index: "EmpNo", sortable: true}, Â Â Â Â Â Â Â Â Â Â Â {label: "Message", name: "Msg", index: "Msg", sortable: true}]
When the HTML for the page is generated, you will see that the grid rows and cells are uniquely named in the format "gridGridName_ColumnName". No problem. However, the filter bars each end up containing id="gs_EmpNo". If we wanted to, for example, default the notification grid to display only the current user's notifications, setting the filter field's value by ID will end up populating the EmpNo field of both grids. Is this a known bug? Is there a workaround?
Â
The second problem is related to our attempt to work around this. We can use jsonmap to ensure each field is uniquely named:
colmodel = [{label: "Sales Order ID", jsonmap: "SoId", name: "SoId", index: "SoId", sortable: true, key: true}, {label: "Sold By", jsonmap: "EmpNo", name: "SoEmpNo", index: "SoEmpNo", sortable: true}, {label: "Bought By", jsonmap: "CustNo", name: "SoCustNo", index: "SoCustNo", sortable: true}]
and so on. However, while this populates the grid correctly when there is no filter, the filtering request uses the name property rather than jsonmap. So the database ends up trying to filter by a field called "SoEmpNo", and promptly throws an exception because that doesn't exist. Is there a grid property we should be using to make it send the correct name back in the filter request, or something?
Â
Thank you!
14:27
Moderators
30/10/2007
Hello,
1. You can solve this problem if you use
$("gs_EmpNo", "#grid1").val(...);
$("gs_EmpNo", "#grid2").val(...);
to differentiate the values,
2. This is not correct - the search try first to use the INDEX property and if it is not found it uses the NAME one.
So you can set the index to post the correct name to database.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
10:41
Moderators
30/10/2007
Hello,
Sorry I put a wrong code. try this:
$("#gs_EmpNo", "#grid1").val(…);
$("#gs_EmpNo", "#grid2").val(…);
where grid1 and grid2 are your grid id.
I missed "#" in my previous post
How you set this in your code?
Kind Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:31
06/06/2014
I noticed that and tried it with the additional # too, but it didn't help. I'm using:
var control = $("#gs_ColumnId", "#gridId"); console.log(control); control.val('desired data');
I'm positive the IDs are spelled and capitalized correctly. When I run that, control contains zero selected objects.
Â
Do you happen to know in what version this functionality was added? We're still on version 4.3.2 due to the possibility of breaking changes.
17:26
Moderators
30/10/2007
Hello,
It all depends where you put this line of code. It is recommended to to this after calling the filterToolbar method.
Another solution of your problem is maybe to use defaultValue in colModel searchoptions. See docs.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
35 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66