How to serialize on all rows not on the filtered ones in Webix datatable

A.G.Progm.Enthusiast

I have webix datatable having 100 rows. Now, assume that when I apply a filter on a particular column, the datatable size reduces and renders 10 matched rows.

I am using serialize() to take the whole table data to a JSON object like below:

var data = {};
var $$mytab = $$('myDataTable');
data = $$mytab.serialize();

Now, the problem is, when the entire table is filtered and showing only 10 rows out of total 100 rows, then the serialize() giving me only those 10 rows into the data object instead of 100.

Is there a way, I can always serialize the entire datatable (i.e 100 rows in this case) irrespective of it is showing filtered data or the entire table ?

After implementing your solution ...

It is giving me the same array in both case when I print them in the browser console with a slight difference in the format.

With your solution, it is giving below output on browser console :

(2) [1497258960089, 1497258960162]

and with mine , as below with values in detail, I can view them if I expand (>) the output :

(2) > [Object, Object]

Earlier when I was using serialize, then the entire structure (with their values) were getting saved into the array. So that later on I can iterate a loop on it and match using 'in' operator to delete a value.

Please consider following code:

mydata = {};

mydata.employee = $$mytab.serialize();

console.log(JSON.stringify(mydata.employee);

for (var i = 0; i < mydata["employee"].length; i++) {
    if("salary" in mydata["employee"][i]) {
        delete mydata["employee"][i]["salary"];
    }
}

In the above code I get following output when I do console.log on mydata.employee :

[{"name":"mark", "company":"abcd", "salary":"100"},{"name":"smith", "company":"pqrs", "salary":"200"}]

However if I use below code as you suggested:

mydata = {};
mydata.employee = [];

$$mytab.eachRow(function(item){mydata.employee.push(item);}, true);

console.log(JSON.stringify(mydata.employee); 

/* Consider the same forloop in this case as above */

This one is just giving me : [1497258960089,1497258960162]

and throws an error as :

Uncaught TypeError: Cannot use 'in' operator to search for 'salary' in 1497258960089

How can I achieve the same thing in your case as well?

fabien-michel

For datatable you can use eachRow method with true as second argument.

To have objects array :

var data = [];
var datatable = $$('my_table')
datatable.eachRow(function(item_id) {data.push(datatable.getItem(item_id));}, true);

For treetable, solution we use is to iterate over data using this low level method :

var treetable = $$('my_table')
treetable.data.each(callback, treetable, true);

To have objects array :

var data = [];
var treetable = $$('my_table')
treetable.data.each(function(item) {data.push(item);}, treetable, true);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to delete all rows under the quick filter column, filtered and unfiltered ones?

From Dev

Get all rows from DataTable including those filtered out

From Dev

rowEdit filtered rows on dataTable Primefaces

From Dev

How to set an ID to a Webix datatable's subview

From Dev

How to create a custom header menu for Webix datatable?

From Dev

GXT3: How to get all items from a TreeStore including the ones filtered out

From Dev

how to get all filtered rows from tablesort.js

From Dev

List all index columns (including filtered ones) in SQL Server

From Dev

How do I get the data from the selected rows of a filtered datatable (DT)?

From Dev

I get all the rows of the third columns "ones" !!

From Dev

How to get data from all selected rows in datatable?

From Dev

How get all rows values into a string from datatable?

From Dev

How get all rows values into a string from datatable?

From Dev

How to read information about filtered data in datatable()?

From Dev

How to get filtered value on Primefaces lazy datatable?

From Dev

Create a new regular table from visible and filtered rows of DataTable

From Dev

Create a new regular table from visible and filtered rows of DataTable

From Dev

For for Numpy array with zeros and ones, how to remove rows with duplicate ones?

From Dev

How do I calculate mean on filtered rows of a pandas dataframe and append means to all columns of original dataframe?

From Dev

Webix remove columns from a DataTable?

From Dev

Laravel Integration with Webix Datatable Editing

From Dev

How to distinct datatable rows?

From Dev

Jquery Datatable get all filtered data across multiple pages

From Dev

How to get the filtered rows in ui-grid?

From Dev

How to SUM rows filtered by multiple criteria

From Dev

How To Write Macro for highlight filtered rows alternatively

From Dev

Delete all rows except 100 most recent ones

From Dev

How can I concatenate all the column values in a row, and then concatenate all rows in a DataTable into a single string?

From Dev

How to check if "all" Textboxes are empty (not individual ones)

Related Related

  1. 1

    How to delete all rows under the quick filter column, filtered and unfiltered ones?

  2. 2

    Get all rows from DataTable including those filtered out

  3. 3

    rowEdit filtered rows on dataTable Primefaces

  4. 4

    How to set an ID to a Webix datatable's subview

  5. 5

    How to create a custom header menu for Webix datatable?

  6. 6

    GXT3: How to get all items from a TreeStore including the ones filtered out

  7. 7

    how to get all filtered rows from tablesort.js

  8. 8

    List all index columns (including filtered ones) in SQL Server

  9. 9

    How do I get the data from the selected rows of a filtered datatable (DT)?

  10. 10

    I get all the rows of the third columns "ones" !!

  11. 11

    How to get data from all selected rows in datatable?

  12. 12

    How get all rows values into a string from datatable?

  13. 13

    How get all rows values into a string from datatable?

  14. 14

    How to read information about filtered data in datatable()?

  15. 15

    How to get filtered value on Primefaces lazy datatable?

  16. 16

    Create a new regular table from visible and filtered rows of DataTable

  17. 17

    Create a new regular table from visible and filtered rows of DataTable

  18. 18

    For for Numpy array with zeros and ones, how to remove rows with duplicate ones?

  19. 19

    How do I calculate mean on filtered rows of a pandas dataframe and append means to all columns of original dataframe?

  20. 20

    Webix remove columns from a DataTable?

  21. 21

    Laravel Integration with Webix Datatable Editing

  22. 22

    How to distinct datatable rows?

  23. 23

    Jquery Datatable get all filtered data across multiple pages

  24. 24

    How to get the filtered rows in ui-grid?

  25. 25

    How to SUM rows filtered by multiple criteria

  26. 26

    How To Write Macro for highlight filtered rows alternatively

  27. 27

    Delete all rows except 100 most recent ones

  28. 28

    How can I concatenate all the column values in a row, and then concatenate all rows in a DataTable into a single string?

  29. 29

    How to check if "all" Textboxes are empty (not individual ones)

HotTag

Archive