ce icon indicating copy to clipboard operation
ce copied to clipboard

Feature Request: get row data in Json format.

Open lyassa opened this issue 6 years ago • 2 comments

Method table.getRowData(row_number) returns the row data in an array. Will be great if we have a similar method that gets the row data in a Json format.

lyassa avatar Dec 03 '19 22:12 lyassa

Actually what I suggested above is doable as follows: var jsonRow = table.getJson()[row_number]; Closing the request.

lyassa avatar Dec 03 '19 22:12 lyassa

Here's my implementation if you wish to use the same api as getRowData(num):

    /**
     * Get a row json by rowNumber
     */
    obj.getRowJson = function(rowNumber) {
        var x = obj.options.columns.length
        var row = obj.options.data[rowNumber];
        var ret = {};
        //ret["line"+rowNumber]={};
        if(row){
          for(var j=0; j < x; j++){
            ret[obj.options.columns[j].name]=row[j];
          }
        }
        return ret;
    }

jabis avatar Mar 01 '20 09:03 jabis