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_Related Related Topics sp_TopicIcon
Editing: Enable/Disable for single rows?
26/02/2012
16:24
Avatar
Wibdi
New Member
Members
Forum Posts: 1
Member Since:
26/02/2012
sp_UserOfflineSmall Offline

Hi folks,

is it possible to enable or disable the edit-function for single rows (datasets)?

For example:

With "formatter actions", you will have the edit and delete-icon placed in each row.

I want these icon to disappear ONLY in special rows (e.g if one cell-value within the row has the value "0")

I gave the "formatter actions" just as an example, because I like the direct visual connection between the icons and the related row.

For me, its even more import to achieve an edit-contoll based on row-values, not only on colModel.

Is there any solution in sight for me?

Thanks & Best Regards

wibdi

12/05/2012
06:35
Avatar
Herbalite
Member
Members
Forum Posts: 5
Member Since:
12/05/2012
sp_UserOfflineSmall Offline

A bit late, had the same problem to solve today. Here is how I solved it: Use jqGrid's events and jQuery

Add or alter the following jqGrid Options when creating the grid:

gridview: false, // If set to true, the event below doesn't fire!

afterInsertRow: function(rowId, rowData, rowElem) {

// rowElem[nnn] column number to compare with (remember Javascript starts indexes at 0, so rowElem[2] selects the 3rd column)

// Adapt the if clause to other comparisions if needed

  if (parseInt(rowElem[7]) == 0) {
    jQuery('tr#'+rowId+' td:last div:first',jQuery(this)).hide();
  }
   return true;
},

This only hides the buttons. You still have to do checkup on the server side.

If you want to disable certain buttons only, you need to tell jQuery more specifically which button you'd want to hide.

If you want to hide the delete button only, do

jQuery('tr#'+rowId+' td:last div:first div.ui-inline-del',jQuery(this)).hide();

If you want to hide the edit button only, do

jQuery('tr#'+rowId+' td:last div:first div.ui-inline-edit',jQuery(this)).hide();

etc.

Final note. If data changes from serve side on row basis, this can be extended to show hidden rows again. However this solution is probably good enough for most cases.

12/05/2012
08:37
Avatar
Herbalite
Member
Members
Forum Posts: 5
Member Since:
12/05/2012
sp_UserOfflineSmall Offline

Another note. The code above assumes that the action buttons are located at the rightmost cell.

If it's different, then you have change

jQuery('tr#'+rowId+' td:last div:first',jQuery(this)).hide();

to

jQuery('tr#'+rowId+' td:nth-child(nnn) div:first',jQuery(this)).hide();

nnn is starting with 1 for the first cell (according to CSS rules)

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
34 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