0

I have something like authorization and lets say if the user doesnt have edit authorization, then I dont want to provide the inline edit option. How is this possible.

if(NotAuthorized)
{ $grid.jqGrid('hideCol', "act");}

UPDATE Have updated the answer as per suggestion below

function evaluateAuthorization(authorizations) {
$("#gridList").find(".ui-inline-edit,.ui-inline-del,.ui-inline-save,.ui-inline-cancel")
.addClass("ui-state-disabled")
.prop("onclick", null)
.prop("onmouseover", null)
.prop("onmouseout", null); 
}

This got me what i wanted.

user2375298
  • 1,001
  • 4
  • 15
  • 28
  • you wrote just about inline edit, but it seems to be exactly you use `formatter: "actions"` in the column "act" and you want to disable buttons in the column added by `formatter: "actions"`. Is it what you mean under "to disable the column"? – Oleg Oct 21 '14 at 11:20
  • Yes My mistake, I am using formatter actions. – user2375298 Oct 21 '14 at 11:26

1 Answers1

1

It I understand you correctly you can disable the buttons inside of loadComplete. The code could be about the following

loadComplete: function () {
    $(this).find(".ui-inline-edit,.ui-inline-del,.ui-inline-save,.ui-inline-cancel")
        .addClass("ui-state-disabled")
        .prop("onclick", null)
        .prop("onmouseover", null)
        .prop("onmouseout", null);
}
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, I have updated the question. What i would want is to control the grid action in another function in someother java script file. – user2375298 Oct 21 '14 at 11:43
  • Yes it worked, I passed my grid ID istead of 'this' and it worked. Thanks sir again :) But if i have to revert it for a true condition , can you please let me know the else part . – user2375298 Oct 21 '14 at 11:48
  • @user2375298: You are welcome! If you need be able to re-enable the buttons then you should *save* old values of `onclick`, `onmouseover` and `onmouseout` properties before removing it by setting to `null`. To restore initial functionality you would set previous values of `onclick`, `onmouseover` and `onmouseout` properties and remove `ui-state-disabled` class (with `removeClass`). – Oleg Oct 21 '14 at 12:51