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

Ajax issue with refreshing multiple radgrid controls

1 Answer 120 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Emran
Top achievements
Rank 1
Emran asked on 25 Feb 2009, 05:39 PM
I have 3 radGrid controls on a page  that require refreshing when a product changes on the fly. 
i have a javascript class containing a method Validate() that calls refreshGrids(with a new product id) .
The RadAjaxManager1_AjaxRequest  event  fires and the grids are repopulated however the grids have not refreshed with the new dataset.

I followed the published examples and tried the solutions on the forum  with no success.
I tried moving the code found in GetData into the RadAjaxManager1_AjaxRequest... still no success.
Please advise.

Regards  Emran

Designer

 
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function refreshGrids(arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
                }
            </script>
        </telerik:RadCodeBlock>
    
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
             <AjaxSettings>
                 <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                     <telerik:UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgAnyTo" />
                        <telerik:AjaxUpdatedControl ControlID="rgSpecificTo"  />
                        <telerik:AjaxUpdatedControl ControlID="rgInformationOnly"  />
                    </telerik:UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        
        <label>Any Switches</label>
        <telerik:RadGrid ID="rgAnyTo" runat="server" AutoGenerateColumns="False" GridLines="None" GroupingEnabled="False" ShowHeader="False" >
            <HeaderContextMenu>
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            </HeaderContextMenu>
            <mastertableview>
                <Columns>
                    <telerik:GridBoundColumn DataField="sFullDisplayRecommendation" UniqueName="sFullDisplayRecommendation"></telerik:GridBoundColumn>
                </Columns>
            </mastertableview>
        </telerik:RadGrid>
                                    
        <label>Specific Switches</label>
        <telerik:RadGrid ID="rgSpecificTo"  runat="server" AutoGenerateColumns="False" GridLines="None" GroupingEnabled="False" ShowHeader="False" >
            <HeaderContextMenu>
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            </HeaderContextMenu>
            <mastertableview>
                <Columns>
                    <telerik:GridBoundColumn DataField="sFullDisplayRecommendation" UniqueName="sFullDisplayRecommendation"></telerik:GridBoundColumn>
                </Columns>
            </mastertableview>
        </telerik:RadGrid>
                                    
        <label>Information </label>
        <telerik:RadGrid ID="rgInformationOnly"  runat="server" AutoGenerateColumns="False"  GridLines="None" GroupingEnabled="False" ShowHeader="False">
            <HeaderContextMenu>
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            </HeaderContextMenu>
            <mastertableview>
                 <Columns>
                    <telerik:GridBoundColumn DataField="sFullDisplayRecommendation" UniqueName="sFullDisplayRecommendation"></telerik:GridBoundColumn>
                </Columns>
             </mastertableview>
         </telerik:RadGrid>      
        
 
  Code behind


        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            GetData(Convert.ToInt32(e.Argument));
        }

        public void GetData(int OrigProductId)
        {
            BusinessLib.LinqEntities.CedarLinqDataContext cedar = new BusinessLib.LinqEntities.CedarLinqDataContext();
            BusinessLib.LinqEntities.LinqClassesDataContext admin = new BusinessLib.LinqEntities.LinqClassesDataContext();
            BusinessLib.LinqEntities.RecommendationSet set = cedar.RecommendationSets.Single(p => p.iRecommendationSetId == 110);

            var resultSet = from rt in cedar.RecommendationTrunks
                            join oProd in cedar.LIVE_Products on new { ProductID = rt.iOriginalProductID, VersionID = set.iDrugVersion } equals
                                new { ProductID = oProd.iProductID, VersionID = oProd.iVersionID }
                            join rProd in cedar.LIVE_Products on new { ProductID = rt.iReplacementProductID, VersionID = set.iDrugVersion } equals
                                new { ProductID = rProd.iProductID, VersionID = rProd.iVersionID } into g2
                            join oBNF in cedar.LIVE_BNFDetails on new { BNFID = oProd.iBNFID, VersionID = set.iDrugVersion } equals
                                new { BNFID = oBNF.iBNFID, VersionID = oBNF.iVersionID }
                            from rProd in g2.DefaultIfEmpty()
                            where
                                rt.iRecommendationSetId == NumberUtils.CIntDef(Session["RecommendationSetId"]) &&
                                rt.bDeleted == false &&
                                rt.bDisabled == false &&
                                rt.iDosageTypeID != 2 &&
                                rt.iOriginalProductID == OrigProductId
                            select rt;
                            
            var rsAny = from rs in resultSet
                           where
                                rs.iRecommendationTypeID == (byte)RecommendationType.Switch &&
                                rs.iDosageTypeID != (byte)DosageType.Specific
                           select rs;
            
            rgAnyTo.DataSource = rsAny;
            rgAnyTo.DataBind();
            rgAnyTo.Rebind();

            var rsSpecfc = from rs in resultSet
                           where
                                rs.iRecommendationTypeID == (byte)RecommendationType.Switch &&
                                rs.iDosageTypeID == (byte)DosageType.Specific                           
                           select rs;
            rgSpecificTo.DataSource = rsSpecfc;
            rgSpecificTo.DataBind();
            rgSpecificTo.Rebind();

            var rsInfo = from rs in resultSet
                         where
                               rs.iRecommendationTypeID == (byte)RecommendationType.Info
                         select rs;
            rgInformationOnly.DataSource = rsInfo;
            rgInformationOnly.DataBind();
            rgInformationOnly.Rebind();
        }

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 26 Feb 2009, 03:15 PM
Hi Emran,

I went through your code, and here are my findings:

Your ajax settings look correct and you properly observed that you need to handle the ajax request (e.g. grid update) on AjaxRequest event of the manager.
However I suggest that you remove the lines which call the Rebind() method from your code and see if it makes any difference.

Additionally, find more information about RadGrid data-binding here.

All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Emran
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or