How to get datatable row object in knockout.js?

Member

by lew , in category: Javascript , 8 months ago

How to get datatable row object in knockout.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , 8 months ago

@lew 

To get a datatable row object in knockout.js, you can use the following steps:

  1. Define a knockout observable array to store the datatable rows:
1
var rows = ko.observableArray([]);


  1. Populate the observable array with the datatable rows:
1
2
3
4
5
// Assuming you have a DataTable instance called "dataTable"
dataTable.rows().every(function(rowIdx, tableLoop, rowLoop) {
    var row = this.data();
    rows.push(row);
});


  1. Access the row object in your view model by using the knockout observable array:
1
2
3
4
5
var viewModel = {
    rows: rows
};

ko.applyBindings(viewModel);


Now, you can access the datatable row objects in your view by using the rows observable array in your knockout bindings.

Related Threads:

How to get 2 distinct rows from 1 row with 3 tables in sql oracle?
How to get row number of a row in laravel?
How to get last inserted row in cakephp?
How to get the id of inserted row in laravel?
How to convert object to json format using knockout.js?
How to get the top row for each group in a column in mysql?