This is a migrated thread and some comments may be shown as answers.

EnableHeaderContextMenu - stopping datasource control parameter binding

3 Answers 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 30 Jan 2015, 11:01 AM
Hi, I have a simple page setup for testing an issue I have found. I have found that if you set  EnableHeaderContextMenu on a radgrid it messe with the binding order on the page. For example:

I have a drop down of users. this drop down is used as a controlparameter for the datasource of the radgrid.

on page load, the dropdown is bound, then the selectedvalue is used as a filter in the sqldatasource for the radgrid. this works as expected

the problem arrises if you make one simple change - set  EnableHeaderContextMenu="true" on the radgrid.

with this set, the radgrid is now bound BEFORE the drop down, meaning you either get no data (if you have cancelselectonnullvalue on the data source0 or as in my case ALL of the data (2,000+ rows) instead of the 20 expected fort he selected user.

any ideas on how to fix this without doing a manual databind of the radgrid on page load?

3 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 04 Feb 2015, 12:02 PM
Hi James,

I have tested the described scenario with our latest version (2014.3 1209) and everything is working correctly when the EnableHeaderContextMenu is enabled.

Following is the example that I have tested locally:
<telerik:RadAjaxPanel runat="server">
    <asp:DropDownList runat="server" AutoPostBack="true" ID="DropDownList1">
        <asp:ListItem Text="text1" Value="1" Selected="True" />
        <asp:ListItem Text="text2" Value="2" />
        <asp:ListItem Text="text2" Value="3" />
    </asp:DropDownList>
 
    <telerik:RadGrid runat="server" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowPaging="true" EnableHeaderContextMenu="true">
    </telerik:RadGrid>
 
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:NorthwindConnectionString %>'
        SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID], [ShipRegion], [ShipName] FROM [Orders] WHERE [EmployeeID] = @id">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="id" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</telerik:RadAjaxPanel>

Can you please try the above on your end and see what differs from your exact scenario.

Looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
James
Top achievements
Rank 1
answered on 04 Feb 2015, 01:13 PM
Konstantin, i'm a bit confused. I opened this forum post before I started the ticket and forgot to close it. my bad.

but you know it doesn't work and I've talked to you about how you have to rebind the drop down before the rad grid datasource.

I hope this bug is on the list to be fixed.

thanks

james
0
James
Top achievements
Rank 1
answered on 04 Feb 2015, 01:16 PM
... if anyone hits this issue here is a work around:

Hi Kostadin, I have a better workaround (although still not ideal!!) that I thought i'd share incase you need to pass it nto anyone else.
instead of rebinding the radgrid on pre render

in your DATASOURCE SELECTING method - first check if not ispostback and there are no items in the drop down (there should be if it's data bound already)... if not then bind the drop down there and then.



ie

Protected Sub dsrcThreads_Selecting(sender As Object, e As SqlDataSourceSelectingEventArgs) Handles dsrcThreads.Selecting   
 'need to putt his in to make sure that the drop down bind before the grid... 
   If Not IsPostBack And cmbOwner.Items.Count < 1 Then        
cmbOwner.DataBind()   
 End If
End Sub
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
James
Top achievements
Rank 1
Share this question
or