RadGrid Rebind and CalculatedColumn

6 posts, 0 answers
  1. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 17 Feb 2009 Link to this post

    I've noticed a problem with the RadGrid control when I call rebind and I have a calculated column in the my grid.

    I'm trying to use the AjaxManager example you show in your online documentation on rebinding the grid by using the AjaxManager's AjaxRequest to rebind the grid when the RadWindow gets closed. The problem I'm getting is that when the ajax request is called the first time after the RadWindow object is closed nothing happens to the grid, only subsequent requests does the code work.

    I looked at the code and it appears that on the first request it throws an error "An item with the same key already exists" from the grid control, which is the same error I received from another application which I reported to you when I used rebind in the delete command. I understand that it's unneccesary to call rebind in the delete command, but calling rebind in another event that has nothing to do with the grid it still throws that error.

    Is there some bug with the calculated column that prevents rebind to be called twice in a row or something? If you could suggest a work-around for this situation that would be great.
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 20 Feb 2009 Link to this post

    Hi,

    Can you please post the code implementation, so that I can try and replicate the issue locally?

    Sincerely yours,
    Yavor
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 16 Mar 2009 Link to this post

    Sorry for taking so long to reply, but here is an example. It may not be practical, but it gets the point across.

    ASPX Page:
    <telerik:RadGrid ID="grdTest" runat="server" AutoGenerateColumns="False" GridLines="None"
                <MasterTableView CellSpacing="-1"
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px" /> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="ColumnID" HeaderText="Column ID" UniqueName="column"
                        </telerik:GridBoundColumn> 
                        <telerik:GridCalculatedColumn Aggregate="Sum" DataFields="Tax,SubTotal" Expression="{0}+{1}" 
                            HeaderText="Calculated Value" UniqueName="column1"
                        </telerik:GridCalculatedColumn> 
                    </Columns> 
                </MasterTableView> 
            </telerik:RadGrid> 
            <br /> 
            <asp:Button ID="btnRebind" runat="server" Text="Rebind Grid" /> 
    Code-Behind:
    Protected Sub grdTest_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdTest.NeedDataSource 
            'create table 
            Dim dtTest As DataTable = New DataTable() 
     
            'build table 
            With dtTest.Columns 
                .Add("ColumnID", GetType(Integer)) 
                .Add("Tax", GetType(Decimal)) 
                .Add("SubTotal", GetType(Decimal)) 
            End With 
     
            'first row 
            Dim drFirst As DataRow = dtTest.NewRow() 
            drFirst("ColumnID") = 1 
            drFirst("Tax") = 13.25 
            drFirst("SubTotal") = 50.84 
     
            'second row 
            Dim drSecond As DataRow = dtTest.NewRow() 
            drSecond("ColumnID") = 2 
            drSecond("Tax") = 15 
            drSecond("SubTotal") = 38.74 
     
            'add to table 
            dtTest.Rows.Add(drFirst) 
            dtTest.Rows.Add(drSecond) 
     
            'bind to grid 
            Me.grdTest.DataSource = dtTest 
        End Sub 
     
        Protected Sub btnRebind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRebind.Click 
            'rebind the grid 
            Me.grdTest.Rebind() 
            Me.grdTest.Rebind() 
        End Sub 

    I've run this test example and returns the error I get when two rebinds happen in the same request, either if I call it explicitly or RadGrid decides to rebind itself, when I have calculated columns in the grid.

    Also, to note, I have tested this out on the latest version of the ASP.NET AJAX RadControls 2009.01.0311.20 with the same result.

    Thanks
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 19 Mar 2009 Link to this post

    Hello,

    I tested the setup which you outlined, and the control behaved as expected.
    Attached to this message, you will find the code, which I used for testing.
    Take a look at it and let me know if this is the expected behavior, or if I am leaving something out.

    Sincerely yours,
    Yavor
    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.
  6. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 23 Mar 2009 Link to this post

    Hi,

    I tried your example and it worked like I was expecting it. Now, when I removed your Telerik trial bin files and put in my purchased Telerik bin files, that's when I saw the error message I was getting. If you could test it out with the purchased version, instead of the Trial version, because the purchased one seems to be the one that throws the error.

    The version I'm using is 2009.01.0311.20 and the one you gave me in the example is 2009.01.0311.35. So I have to assume that's the reason why yours works correctly and mine doesn't.

    Thanks.
  7. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 26 Mar 2009 Link to this post

    Hi,

    I tested with the dev version as well, and sure enough, the control behaved as expected.
    If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your setup, along with the unwanted behavior. I will debug it locally, and advise you further.

    Best wishes,
    Yavor
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017