Set default values with js

QuestionsSet default values with js
Alex asked 8 years ago


Is it somehow possible to set the values of the last row that was added as default values for the add row dialog.


1 Answers
Abu Ghufran answered 8 years ago


You will need some extra JS coding in afterShowForm event.

$opt["add_options"]["afterShowForm"] = 'function() { fill_add_form(); }';

In this callback, you can read the values of last row of grid, e.g.

function fill_add_form()

// get all rows as array
var rows = $('#list1').getRowData();

// Now this last_row contains the object of last displayed row of grid. (not the last page's last row)
var last_row = rows[rows.length-1];

// Use jquery to set input fields data according to last_row object
jQuery("input[name=gender]").val( last_row.gender );


You can fill other rows in same manner.

Your Answer

16 + 17 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?