Hello,
I am facing issue while using DropDownProvider inside WebDataGrid.
I have above Grid which has 5 DropDownProvider. So when I select any item from 'Product Type' DropDownProvider ,'Product Name' DropDownProvider items should be filtered based on selected value.
For this requirement I have added below source code for Product Type' DropDownProvider...
<ig:DropDownProvider ID="PortfolioNameDropDownProvider" EditorControl-DisplayMode="ReadOnly"> <EditorControl ID="EditorPortfolioName" ClientIDMode="Predictable" runat="server" DisplayMode="DropDownList" TextField="PortfolioName" ValueField="ID" DataKeyFields="ID" OnValueChanged="EditorPortfolioName_ValueChanged"> <DropDownItemBinding ValueField="PortfolioName" TextField="PortfolioName"/> </EditorControl> </ig:DropDownProvider>
protected void EditorPortfolioName_ValueChanged(object sender, DropDownValueChangedEventArgs e) { //Code logic for Data filter for based on value selected in PortfolioNameDropDownProvider }
So,the issue I am facing is above event is not triggered when I am selecting any value from Product Type' DropDownProvider. Even I tried by putting breakpoints in the above event and debugging but the event is not triggered.Can you please help on this.
Hello Rakesh,
Thank you for posting in our community.
By enabling the ValueChanged AutoPostBackFlag the OnValueChanged event should trigger:
<ig:DropDownProvider ID="PortfolioNameDropDownProvider" EditorControl-DisplayMode="ReadOnly"> <EditorControl ID="EditorPortfolioName" ClientIDMode="Predictable" runat="server" DisplayMode="DropDownList" TextField="PortfolioName" ValueField="ID" DataKeyFields="ID" OnValueChanged="EditorPortfolioName_ValueChanged" AutoPostBackFlags-ValueChanged="On"> <DropDownItemBinding ValueField="PortfolioName" TextField="PortfolioName" /> </EditorControl> </ig:DropDownProvider>
Please let me know if you need any further assistance with this matter.
Hi Martin,
Thanks for the response but I am facing an issue with AutoPostBackFlags-ValueChange="On". Issue is when I select value in first DropDownProvider,based on the value selected in 1st DropDownProvider,2nd DropDownProvider's data is populated but 1st DropDownProvider valuie is reset to DefaultValueText(--Choose Portfolio Type--).
To resolve this I have included Javascript for first dropdownprovider.Below is the code...
function dgCompatibilityViewData_DropDown_SelectionChangedPortfolioName(sender, eventArgs) { var selectedItemText = eventArgs.getNewSelection()[0].get_text(); var selectedItemValue = eventArgs.getNewSelection()[0].get_value(); var dropdowneditor2 = ig_controls.EditorProductName; dropdowneditor2.loadItems(selectedItemValue, false);
}
Below is the aspx source code for this...
<ig:DropDownProvider ID="PortfolioNameDropDownProvider"> <EditorControl ID="EditorPortfolioName" runat="server" ClientIDMode="Predictable" DisplayMode="DropDownList" TextField="PortfolioName" ValueField="ID" DataKeyFields="ID" Width="364px"> <DropDownItemBinding TextField="PortfolioName" ValueField="ID"></DropDownItemBinding> <ClientEvents SelectionChanged="dgCompatibilityViewData_DropDown_SelectionChangedPortfolioName"/> </EditorControl> </ig:DropDownProvider>
Below is the source code for 2nd Dropdownprovider..
<ig:DropDownProvider ID="ProductNameDropDownProvider"> <EditorControl ID="EditorProductName" runat="server" ClientIDMode="Static" DisplayMode="DropDownList" TextField="ProductName" ValueField="ID" DataKeyFields="ProductName" Width="364px" OnItemsRequested="EditorPortfolioName_ItemsRequested"> <DropDownItemBinding TextField="ProductName" ValueField="ID"></DropDownItemBinding></EditorControl> </ig:DropDownProvider>
Below is the EditorPortfolioName_ItemsRequested code..
protected void EditorPortfolioName_ItemsRequested(object sender, DropDownItemsRequestedEventArgs e) { //logic to reset 2 nd Dropdownprovider and populate the date based on nvalue selected from 1st Dropdownprovider }
Everything is good for first time i.e when I select value from first dropdownprovider the second dropdownprovider displayed value is defaultValue(--Choose Product Name--) and data populated based on value selected from first Dropdownpeovider & I select the value from second Dropdownprovider.But for the 2nd time when I change the value in 1st Dropdownprovider,second Dropdownprovider is not reset to default text(--Choose Product Name--) and already selected value is displayed but data is changing based on the value selected from first Dropdownprovider
I think I have to do some modification in Javascript code but not getting what to do.Can you please suggest me in this.
Thanks,
Rakesh
Hi Rakesh,
When the AutoPostBackFlags-ValueChange is enabled, the event OnValueChanged is raised parallel with the ClientEvents-SelectionChanged one, however, because it will cause a post-back, the client-side handler won't work correctly.
I have created and attached a sample demonstrating a possible solution for your requirement without the need for AutoPostBackFlags. Please test it on your side and let me know whether it solves your issue.
Looking forward to hearing from you.
2818.Sample.zip