jQWidgets Forums

jQuery UI Widgets Forums Grid Hide Button For Certain Row

This topic contains 6 replies, has 2 voices, and was last updated by  C.S.Putera 11 years ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Hide Button For Certain Row #54869

    C.S.Putera
    Participant

    Hello, I have a grid displaying a list of Item. There are buttons : View, Edit & Delete in the grid. I want to show buttons according to their access rights, some user may edit a record and some user don’t. How can I show / hide button for certain row only ? Thank you

    Hide Button For Certain Row #54871

    C.S.Putera
    Participant

    This is what I’ve come up with so far. I use ‘cellsrenderer’ like this :

    
    function (rowIndex, dataField, value, defaultHtml) {
     var rowData = $("#jqxgrid").jqxGrid("getrowdata", rowIndex);
     var isAccessable = false;
     // I've defined accessableIds before
     for(var prop in accessableIds) {
      if(accessableIds.hasOwnProperty(prop)) {
       if(accessableIds[prop] === rowData.id)
         isAccessable = true;
      }
     }
     if(isAccessable) 
      return "View";
     else
      $("#jqxgrid").jqxGrid("setcellvalue", rowIndex, dataField, "No Value");
    }
    

    But it shows error in console : “too much recursion”.

    Am I missing anything ? Please help, tq

    Hide Button For Certain Row #54873

    C.S.Putera
    Participant

    I think I figure out why it shows error “too much recursion”. When I setcellvalue, it will trigger the function cellsrenderer again, right ? Is there a way that I could set the cell value to null or empty without triggering the cellsrenderer ? Please help, tq

    Hide Button For Certain Row #54875

    Peter Stoev
    Keymaster

    Hi C.S.Putera,

    “setcellvalue” will always require a re-render operation and so the “cellsrenderer” will be called again. I suggest you to do not call “setcellvalue” in “cellsrenderer” or implement some loops inside that function, because that will affect the Grid’s performance. In addition, the rowData is available as parameter of “cellsrenderer” in the current version so it’s not necessary to call “getrowdata”, too.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Hide Button For Certain Row #54876

    C.S.Putera
    Participant

    Thank you for the reply. Is there any solution on how I could hide the button ? Based on my code above, my code will check if the row’s ID is allowed to be accessed and if not, then hide button. Please help, tq

    Hide Button For Certain Row #54879

    Peter Stoev
    Keymaster

    Hi C.S.Putera,

    Unfortunately, it is not possible to hide a button in the button’s column.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Hide Button For Certain Row #54894

    C.S.Putera
    Participant

    Okay, tq for the support.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.