How to get all column names from KendoGrid?

I need all the kendo grid names to perform some operations on the grid. Please help me?

+4
source share
1 answer

Try the following code.

  var columnsNames ="";
  var columns = $("#CircuitGrid").data("kendoGrid").columns;
        if (columns.length > 0) {
            for (var i = 0; i < columns.length; i++) {
                var col = columns[i];
                if (col.field != undefined) {
                    if (columnsNames.length < 1)
                        columnsNames = col.field;
                    else
                        columnsNames += "~" + col.field;
                }
            }
        }
        console.log("columnsNames = " + columnsNames);

Enter the event code (let's assume that on the button click) where you want the column name.

+5
source

All Articles