0

I want to refresh a select drop down on my edit form.

At the moment I have $("#SalesName").refresh but this doesnt work. I have this in the colModel editoptions:{dataUrl:'SalesDropDownGrid.php'}.

Any help is appreciated.

Thanks

JC75
  • 77
  • 2
  • 4
  • 12
  • Sorry, but it's not clear what problem you have. **Why** you need to refresh the select box. Is the select box depend on another select box in the grid or your problem is that the data from 'SalesDropDownGrid.php' will be changed and you want that the request to the server (to 'SalesDropDownGrid.php') will be made during every opening of the Edit form? – Oleg Mar 07 '12 at 17:51
  • I have a select box on the edit form showing a list of Salesman. But I also need the user to be able to add a new Salesman to the database and for that new Salesman to be appear in the select list. So in the elmsuffix I have put a link which opens a dialog where the user can enter a new Salesman. I then need that Salesman to appear in the Select list. So I think I need to refresh the select box somehow. Thanks – JC75 Mar 08 '12 at 08:58

1 Answers1

0

If you would use recreateForm: true option of the form editing then the edit form will be recreated every time when the user open the form. So the select will be filled with the items returned by "SalesDropDownGrid.php" (from editoptions.dataUrl).

If you would set Cache-Control: max-age=0 HTTP header in the response from "SalesDropDownGrid.php" the results will be not cached and the select will be filled with the current list of "Salesman". If you have some problems with the setting of HTTP headers in your PHP code you can use alternatively

ajaxSelectOptions: { cache: false }

see the answer.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg.Thanks for that. However I also need the list of Salesman to be refreshed while I am still on the editform. The user will add a Salesman by clicking a link on the edit form and I need for that Salesman to be added to the list straight away. Thanks – JC75 Mar 08 '12 at 09:47
  • @JC75: Sorry, but I can't understand that. Which "link on the edit form" you mean? If you customized the edit form you should first post the code of the form because you have the described problems *only because of your customization*. If you gives the user some interface **inside of edit form** to change the list of select items you have to change the corresponding select. See how it is implemented in [the answer](http://stackoverflow.com/a/6499309/315935) for example. – Oleg Mar 08 '12 at 10:15
  • Hi Oleg. Is there not something like $("#SalesName").refresh or $("#SalesName").append. I dont really want to go through 200 lines of code just to reload a select box? Thanks – JC75 Mar 08 '12 at 10:30
  • @JC75: There are no "refresh". You can use `jQuery.append` to append manually an ` – Oleg Mar 08 '12 at 10:57
  • Thanks for your help Oleg. Really appreciate it. Sorry if i sound a bit frustrated but im fairly new to web based programming and find it very frustrating sometimes that it takes me days or weeks to do the simplest things!! Your help is invaluable! I will take on board what you have said and will come back to my problem at a later date. Thanks again. Should I mark your answer as accepted? – JC75 Mar 08 '12 at 11:22
  • @JC75: You are welcome! If you new in web development and you have to invest more time to have better understanding. If you not sure you should better post more code fragments. The code will clear many things and you can receive tips to improve or reorganize your code. When and whether to accept the answer you should decide better yourself. :-) Best wishes! – Oleg Mar 08 '12 at 11:34
  • Thanks Oleg! I will be back when I have more time and patience! – JC75 Mar 08 '12 at 11:36