Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Filtering Multiple Grids
07/06/2014
00:50
Avatar
MartinDawson
Member
Members
Forum Posts: 3
Member Since:
06/06/2014
sp_UserOfflineSmall Offline

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!

09/06/2014
14:27
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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/06/2014
01:05
Avatar
MartinDawson
Member
Members
Forum Posts: 3
Member Since:
06/06/2014
sp_UserOfflineSmall Offline

1. I'm sorry, Tony, but that selector does not work. It returns an empty selection every time.

 

2. I assure you that the jsonmap property works quite well for the server-to-page data flow.

10/06/2014
10:41
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

10/06/2014
16:31
Avatar
MartinDawson
Member
Members
Forum Posts: 3
Member Since:
06/06/2014
sp_UserOfflineSmall Offline

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.

11/06/2014
17:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information