Set default values with js

QuestionsSet default values with js
Alex asked 9 years ago

Hi

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

Thanks
Alex

1 Answers
Abu Ghufran answered 9 years ago

Hello,

You will need some extra JS coding in afterShowForm event.

$opt["add_options"]["afterShowForm"] = 'function() { fill_add_form(); }';
..
$g->set_options($opt);

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

<script>
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 );

}
</script>

You can fill other rows in same manner.

Your Answer

1 + 19 =

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?