How to use data.add()

I am a beginner.

i want grid add row

button event click ->

ex) var grid_format = { columns: [ { width:100, id: “check”, type: “boolean” header: [{ text: “SELECT” }]},
{ width:250, id: “contents”, header: [{ text: “CONTENT” }]},
{ width:250, id: “writer”, header: [{ text: “WRITER”}]} ] };

grid.data.add( {“id”: Math.floor(Math.random( )*100),
“check”: “”,
“contents”: “”,
“writer”: “”}, 0); — xx

—>
grid.data.add( grid_format columns(?), 0 );

Your code works well for me:
https://snippet.dhtmlx.com/5odd6o7s
Could you please, clarify what problem do you have with the row adding?

1 Like

grid.data.add( {“id”: Math.floor(Math.random( )*100),
“check”: “”,
“contents”: “”,
“writer”: “”}, 0); —> Not this way.


Thank you for your reply.

I want to get it from the declared grid format.

ex)

var grid_format = { columns: [ { width:100, id: “check”, type: “boolean” header: [{ text: “SELECT” }]},
{ width:250, id: “contents”, header: [{ text: “CONTENT” }]},
{ width:250, id: “writer”, header: [{ text: “WRITER”}]} ] };

grid.data.add( get grid format method? <<---------- , 0 );

Another question.

I’d like to have you enter only numbers in the added row.

this is the only available format of the add() method.
Coud you please clarify what result dio you expect from adding a “grid format” to the add() method?

I’d like to have you enter only numbers in the added row.

You place the content of the add() method by yourself. And you can control these values manually before placing it to the add() method