Loading table with an interactive row event and how to exclude a column or cell

I have this function to click on a line:

$("#table").on("click-row.bs.table", function (row, $el, field) {
  if (column != 4) {

  }
});

and what condition can I add that would exclude a particular column or cells in a column? I can not find in row, $el or fieldthings that will be identified for ex. cell index.

+4
source share
4 answers

Finally, I found the answer to my question (if someone needs it, it would be easier than I thought):

 $("#table").on("click-cell.bs.table", function (field, value, row, $el) {
    if (value !="column_name"){
      //the code
    }
 });

here is an example (with access to all values ​​of a clicked string): jsfiddle

+4
source

you can do something like this:

$("table").on("click", "tr td", function () {
   var col = $(this).index();
   if(col != 2){
     console.log("OK");
   }        
});

, $.index() 0 ( 4 3)

JSFIDDLE

0
  $("#summaryTable tbody tr td").click(function(){
    var col = ($(this).index());

    if(col == 2 || col == 1)
    {
        alert("do nothing");
    }
        alert("do something");
    }
  });

This will happen when the first column is clicked, but not the second or third.

Tables are very similar to arrays, 0 is the first, so if we had 3 columns in the table, you would have a column of 0,1,2.

You can add more values ​​to the if statement

Hope this helps

0
source

I find it best to listen to whole clicks with click-row.bs.table. Then columnsit is plain JSON with the keys that you provided from the variable t.

 $("#summaryTable").on("click-row.bs.table", function (editable, columns, row) {
   console.log("columns:", columns);

   // You can either collect the data one by one
   var params = {
         id: columns.id,
         type: columns.type,
       };
   console.log("Params:", params);

   // OR, you can remove the one that you don't want
   delete columns.name;
   console.log("columns:", columns);
    });
0
source

Source: https://habr.com/ru/post/1654708/


All Articles