Custom mRender for form with rowId

Custom mRender for form with rowId

pharokpharok Posts: 1Questions: 1Answers: 0
edited November 2014 in Free community support

Hello,

I'm trying to create a table, with an add button, for a form.
Here is my code: http://jsfiddle.net/kLudLnms/3/

I have set the mRender option, to be able to render an input element.

"mRender": function ( data, type, full ) {
  return '<input type="text" class="form-control" id="users['+ full.DT_RowId +'].name" name="users['+ full.DT_RowId +'].name" value="'+full.data+'">';
}

When I use the row.add function to insert new data, the variable data, and the full.DT_RowId are both undefined

ex:
mRender function:

return '<input type="text" class="form-control" id="users['+ full.DT_RowId +'].name" name="users['+ full.DT_RowId +'].name" value="'+data+'">';

rendered:

<input class="form-control" id="users[undefined].name" name="users[undefined].name" value="undefined" type="text">

I've managed to have the expected result using the following modification on add and mRender functions, but I don't feel like it's the correct way to do this.
http://jsfiddle.net/kLudLnms/4/

How to achieve this?
Thanks a lot!

Pharok

This discussion has been closed.