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:
|
1 2 3 |
colmodel = [{label: "Sales Order ID", name: "SoId", index: "SoId", sortable: true, key: true},<br /> Â Â Â Â Â Â Â Â Â Â Â {label: "Sold By", name: "EmpNo", index: "EmpNo", sortable: true},<br /> Â Â Â Â Â Â Â Â Â Â Â {label: "Bought By", name: "CustNo", index: "CustNo", sortable: true}] |
|
1 2 3 |
colmodel = [{label: "Notification ID", name: "NoteId", index: "NoteId", sortable: true, key: true},<br /> Â Â Â Â Â Â Â Â Â Â Â {label: "User", name: "EmpNo", index: "EmpNo", sortable: true},<br /> Â Â Â Â Â Â Â Â Â Â Â {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:
|
1 2 3 |
colmodel = [{label: "Sales Order ID", jsonmap: "SoId", name: "SoId", index: "SoId", sortable: true, key: true},<br /> {label: "Sold By", jsonmap: "EmpNo", name: "SoEmpNo", index: "SoEmpNo", sortable: true},<br /> {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!
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top