jTable Conditional show\hide edit and delete buttons based on owner of data

前端 未结 3 2015
清歌不尽
清歌不尽 2021-01-07 03:00

Im using jTable to display CDs info and a child table to show reviews of that CD. I want to be able to only show the edit\\delete buttons on the rows for the user that is lo

3条回答
  •  囚心锁ツ
    2021-01-07 03:37

    The following worked for me. It hides the edit/delete button on rows where the current user is not the authorized user. Note: I added a column for authorizedUser in the mysql table and use that to know if the user is allowed or not.

    rowInserted: function(event, data){
         var $currentUser='';
         if (data.record.authorizedUser != $currentUser) {
            data.row.find('.jtable-edit-command-button').hide();
            data.row.find('.jtable-delete-command-button').hide();
         }
      },
    

提交回复
热议问题