What is the recommended way to set the selected value of a dropdownprovider(WebDropDown) on the client side via javascript?
I have a WebHeirarchicalDataGrid with a column that has a DropDownProvider as the editor. On the client side, when I add a new row I want to be able to set the selected value for this dropdown. With the old UltraWebGrid you could just set the value and things just worked. With the new WHDG, setting the value also sets the display text for the dropdown unless you specify the text to display.
I am looking for something like setSelectedItem() or setSelectedIndex(). I saw one post which suggested setting the innerhtml of the element and this would auto select the appropriate item, this seems like a hack...
Hi elPato79,
Thank you for the follow up. If you have any other questions or concerns please do not hesitate to ask.
Thanks for the reply Nikolay,
Your suggestion works well when the text and value are the same, in my scenario text(display) value and actual value are different.
I appreciate your help with this, I am just going to write this off as a minor nuance between UltraWebGrid and WebHeirarchicalDataGrid. I'll adjust my user control to manage both default Text and Value and then set both on row added event.
Hello elPato79,
You could only set the value of the cell, the text will be automatically set equal to the value.
Hi Nikolay,
My scenario is:
-Click a button which calls js function to Add a new row client side
-Within the same function after row is added, I want to set the selected value for a specified cell that has a dropdownprovider associated to it.
-The provider is associated with CellEditing column setting
Currently if I set the text and the value of the cell, things appear to get wired up correctly, but this is not efficient because then I need to know both the value and text that I want to set the cell too. For a single page with a grid, this isnt that big of a deal, but in my case I am creating a user control that is going to be used on hundreds of pages and I would prefer not to have to maintain both text and value for each dropdown I want to default. Again with the old UltraWebGrid I could just set the value and be done with it, I am just looking for a comparable approach.
Thanks for your help.
Could you please clarify your scenario? On which event are you trying to set the value of the editor provider and is this provider associated with CellEditing or RowAdding column settings?