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

Rebind fro javascript

2 Answers 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Simmonds
Top achievements
Rank 1
David Simmonds asked on 29 Apr 2010, 05:07 AM
I have a button and a couple of textboxes on a form with two radgrid controls. I fill out the textboxes and click the button. The button calls javascript when clicked. In the handler I call get_masterTableView().rebind(); for each  radgrid. Only the last grid that I call rebind for actually rebinds. The grids both use different LinqDataSources. Each LinqDataSource has the Selecting event wired up which returns a linq result of columns. Why is only one radgrid rebinding?

Each radgrid looks similar to this one. The only difference is the ID, DataSourceID, and name of the OnGridCreated handler.

                <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" Height="100%" Width="100%" LoadingPanelID="RadAjaxLoadingPanel1">
                    <telerik:RadGrid ID="RadGridEnhanced" runat="server" AllowPaging="True"
                            Skin="Office2007" GridLines="None"
                            AutoGenerateColumns="False"
                            AllowAutomaticDeletes="True" ShowFooter="True"
                        DataSourceID="LinqDataSourceEnhancedAdvertising" >
                        <ClientSettings>
                            <selecting allowrowselect="True" />
                            <ClientEvents OnGridCreated="GetGridObjectEnhanced"></ClientEvents>
                        </ClientSettings>
                        <mastertableview datakeynames="ID" datasourceid="LinqDataSourceEnhancedAdvertising">
                            <Columns>
                                <telerik:GridBoundColumn DataField="PromotionStartDate"
                                    DataFormatString="{0:d}" DataType="System.DateTime" FooterText="Total"
                                    HeaderText="Promotion Start Date" SortExpression="PromotionStartDate"
                                    UniqueName="PromotionStartDate">
                                    <HeaderStyle Width="100px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="PromotionEndDate" DataFormatString="{0:d}"
                                    DataType="System.DateTime" HeaderText="Promotion End Date"
                                    SortExpression="PromotionEndDate" UniqueName="PromotionEndDate">
                                    <HeaderStyle Width="100px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn Aggregate="Sum" DataField="DiscountValue"
                                    DataFormatString="{0:C}" DataType="System.Double" DefaultInsertValue=""
                                    FooterAggregateFormatString="{0:C}" HeaderText="Discount Value"
                                    SortExpression="DiscountValue" UniqueName="DiscountValue">
                                    <HeaderStyle Width="100px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="CityRegion" DataType="System.String"
                                    HeaderText="City/Region" SortExpression="CityRegion" UniqueName="CityRegion">
                                    <HeaderStyle Width="100px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="IndustryType" DataType="System.String"
                                    HeaderText="Industry Type" SortExpression="IndustryType"
                                    UniqueName="IndustryType">
                                    <HeaderStyle Width="100px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Display="False"
                                    HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </mastertableview>
                    </telerik:RadGrid>
                </telerik:RadAjaxPanel>

    <asp:LinqDataSource ID="LinqDataSourceEnhancedAdvertising" runat="server"
        AutoPage="False" ContextTypeName="CharityCheck.CharityCheckEntities"
        onselecting="LinqDataSourceEnhancedAdvertising_Selecting"
        TableName="EnhancedBusinessAdvertisingsSet">
    </asp:LinqDataSource>

2 Answers, 1 is accepted

Sort by
0
David Simmonds
Top achievements
Rank 1
answered on 29 Apr 2010, 06:30 AM
Note: Here is my hander tor the button:

            function webImageButtonSearch_Click(oButton, oEvent) {
                RadGridExclusive.get_masterTableView().rebind();
                RadGridEnhanced.get_masterTableView().rebind();
            }

And the code for the Selecting event:

        protected void LinqDataSourceEnhancedAdvertising_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            CharityCheckEntities entities = new CharityCheckEntities();
            var data = from en in entities.EnhancedBusinessAdvertisingsSet
                       from company in entities.CompanySet
                       where en.CompanyID == company.ID &&
                             ((WebTextEditBusinessName.Text.Trim().Length != 0)
                                ? company.CompanyName == WebTextEditBusinessName.Text.Trim()
                                : true) &&
                              ((RadComboBoxIndustry.SelectedValue.Length != 0)
                                ? company.TypeOfIndustry == RadComboBoxIndustry.SelectedValue
                                : true) &&
                              ((WebTextEditCityRegion.Text.Trim().Length != 0)
                                ? company.City == WebTextEditCityRegion.Text.Trim()
                                : true)
                       select new
                       {
                           en.ID,
                           en.PromotionStartDate,
                           en.PromotionEndDate,
                           en.DateSubmitted,
                           en.Fee,
                           en.WhoReceives,
                           DiscountValue = ((double)en.SellProductFor * en.Discount / 100),
                           IndustryType = company.TypeOfIndustry,
                           CityRegion = company.City
                       };
            e.Result = data;
            e.Arguments.TotalRowCount = data.Count();
        }
0
Tsvetoslav
Telerik team
answered on 04 May 2010, 04:34 PM
Hello David,

What is actually happening in your application scenario is that each call to the rebind method of the table-view is throwing an ajax request to perform the operation on the server. Each subsequent ajax request cancels the previous one and thus only the last rebind() call succeeds. I'd recommend that you use the RadAjaxPanel's ajaxRequest() event to throw an ajax request, capture it on the server through the panel's OnAjaxRequest event and rebind the four grids on the server.

Hope this information helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
David Simmonds
Top achievements
Rank 1
Answers by
David Simmonds
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or