HI Abu,
I have some Col editoptions as: array("defaultValue"=> getValue());
I take the value from a php function, all works fine, but after i add a record and try to add a new one, the values arent refreshes, i mean, Grid call the function only first time.
I use it to auto generate a username and after first record added the second time i try to add a new one the username is the same, as it must be unique it doesnt work for me.
¿Is there any way to force to refresh those values?
I have seen that even when i use the refresh button on grid still remains the last values, only reloading the page the values changes.
Thanks in advance.
Mike
Hello,
This does not work because, the defaultValue code is executed only once at time of grid load.
When you open the add dialog again, it all works on clientside using JS.
Alternate solution could be to use an event 'afterShowForm' and call an ajax request, that will load the new username value and then set it in textbox.
$grid["add_options"]["afterShowForm"] = "function(){ load_username(); }";
$g->set_options($grid);
<script>
function load_username()
{
// make ajax call to load new username and set it in textbox (username) – $('#username').val('abc');
}
</script>