Editoptions, defaultValue not updated

QuestionsEditoptions, defaultValue not updated
Miguel asked 5 years ago

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.


2 Answers
Abu Ghufran answered 5 years ago


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(); }";

function load_username()
// make ajax call to load new username and set it in textbox (username) – $('#username').val('abc');

Miguel answered 5 years ago

Thanks Abu

Great Support 😉

Your Answer

15 + 14 =

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 / 5. Vote count:

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

Let us improve this post!