Editoptions, defaultValue not updated

QuestionsEditoptions, defaultValue not updated
Miguel asked 10 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.

Mike

2 Answers
Abu Ghufran answered 10 years ago

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>

Miguel answered 10 years ago

Thanks Abu

Great Support 😉

Your Answer

0 + 5 =

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?