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

Grid MasterTableView disappears with move to 2012 Q3 version from 2010 Q3

19 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VITALY
Top achievements
Rank 1
VITALY asked on 13 Dec 2012, 03:36 PM
I'm using Grid Template Column with checkboxes. Grid loads normally but MasterTableView disappears when you are clicking any checkbox in .Grid Template Column. Worked fine in 2010 Q3. Problem happened with move to 2012 Q3. Project was updated through VS2010 Telerik menu: Update to the latest version.

Grid Template Column:

<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" AllowFiltering="False">
    <HeaderTemplate>
     <asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="true" runat="server"></asp:CheckBox>
    </HeaderTemplate>
    <ItemTemplate>
        <asp:CheckBox id="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="true" runat="server"></asp:CheckBox>
    </ItemTemplate>
      
        <HeaderStyle Width="95px" />
</telerik:GridTemplateColumn>

Code behind:
Protected Sub ToggleSelectedState(ByVal sender As Object, ByVal e As EventArgs)
    Dim headerCheckBox As CheckBox = CType(sender, CheckBox)
    For Each dataItem As GridDataItem In OMSGrid.MasterTableView.Items
        CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = headerCheckBox.Checked
        dataItem.Selected = headerCheckBox.Checked
    Next
End Sub
 
Protected Sub ToggleRowSelection(ByVal sender As Object, ByVal e As EventArgs)
    CType(CType(sender, CheckBox).NamingContainer, GridItem).Selected = CType(sender, CheckBox).Checked
End Sub
 
Protected Sub OMSGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles OMSGrid.ItemCreated
    If TypeOf e.Item Is GridDataItem Then
        AddHandler e.Item.PreRender, AddressOf OMSGrid_ItemPreRender21
    End If
End Sub
 
 
Protected Sub OMSGrid_ItemPreRender21(ByVal sender As Object, ByVal e As EventArgs)
    If Not CType(sender, GridDataItem)("CheckBoxTemplateColumn").FindControl("CheckBox1") Is Nothing Then
        CType(CType(sender, GridDataItem)("CheckBoxTemplateColumn").FindControl("CheckBox1"), CheckBox).Checked = CType(sender, GridDataItem).Selected
     End If
End Sub

This code is from Telerik code samples. Again, it's working fine with 2010 Q3. 

Thank you for your help.

Regards,

Vitaly

19 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Dec 2012, 01:47 PM
Hello Vitaly,

Could you please let me know how the RadGrid control is bind? Sharing the whole RadGrid markup as well as the related code behind will help us further investigate on the issue.
Also please do let me know if the described problem could be replicated in some of ours online demos?

All the best,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
VITALY
Top achievements
Rank 1
answered on 18 Dec 2012, 02:23 PM
Dear Maria,

Your samples are working fine - again, I'm just using the code I've copied from your site: code for template column with check boxes (code in my original post).
This is my grid markup and grid bind code:
<telerik:RadGrid ID="OMSGrid" ShowFooter="True" runat="server" OnItemDataBound="OMSGrid_ItemDataBound"  
                    AllowFilteringByColumn="True" AllowSorting="True"
                      GridLines="None" Width="1238px" ShowHeader="true" AutoGenerateColumns="False" 
                      AllowMultiRowEdit="True" AllowMultiRowSelection="True">
                    <MasterTableView DataKeyNames="OrderID" Width="1238px" Font-Size="8" HeaderStyle-Font-Size="8"
                        GridLines="Horizontal">
                        <RowIndicatorColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Visible="False">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <Columns>
                            
                        <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" AllowFiltering="False">
                            <HeaderTemplate>
                             <asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="true" runat="server"></asp:CheckBox>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox id="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="true" runat="server"></asp:CheckBox>
                            </ItemTemplate>
                             
                                <HeaderStyle Width="95px" />
                        </telerik:GridTemplateColumn>
                        
                            <telerik:GridTemplateColumn    SortExpression="ORDERID" DataField="ORDERID" HeaderText="Order" UniqueName="column1">
                                <ItemTemplate>
                                    <asp:HyperLink   runat="server" ID="orderLnk"
                                        Text='<%# DataBinder.Eval(Container, "DataItem.ORDERID") %>'></asp:HyperLink>
                                </ItemTemplate>
                             
                                <HeaderStyle Width="130px" />
                             
                            </telerik:GridTemplateColumn>
                            
                            
                            
                            <telerik:GridBoundColumn DataField="ORDERID" HeaderText="Order" SortExpression="ORDERID"
                                UniqueName="Order" Visible="False">
                            </telerik:GridBoundColumn>
                            
                        </Columns>
                        <AlternatingItemStyle BackColor="#7CB3B8"  
                             Wrap="True" />
                    </MasterTableView>
                    <ClientSettings AllowRowsDragDrop="True">
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>
                   <HeaderContextMenu EnableTheming="True">
                       <CollapseAnimation Duration="200" Type="OutQuint" />
                   </HeaderContextMenu>
                   <FilterMenu EnableTheming="True">
                       <CollapseAnimation Duration="200" Type="OutQuint" />
                   </FilterMenu>
                </telerik:RadGrid>

  
GRID BIND CODE:
Dim results As IList(Of Order) = New List(Of Order)()
 
           Dim dsU2Data As DataSet = New DataSet
           dsU2Data = GetDataset()
 
           Try
 
 
               If dsU2Data.Tables.Count > 0 Then
                   If dsU2Data.Tables(0).Columns().Count > 2 Then
                        
                       results = New List(Of Order)()
                       For Each dr As DataRow In dsU2Data.Tables(0).Rows
 
                           Dim neword As New Order(dr.Item("@ID"), dr.Item("CONSNAME").ToString(), String.Format("{0:d}", dr.Item("ENTRYDATE")), _
                                   String.Format("{0:d}", dr.Item("CANCELDATE")), String.Format("{0:d}", dr.Item("STARTDATE")), _
                                   dr.Item("PONUM").ToString(), dr.Item("SHIPVIA").ToString(), dr.Item("BATCHNO").ToString(), _
                                   dr.Item("ORDERSTATUS").ToString(), dr.Item("CTNS").ToString(), dr.Item("WGT").ToString(), _
                                   dr.Item("CUBE").ToString(), dr.Item("CITY").ToString(), dr.Item("STATE").ToString(), _
                                   dr.Item("DC").ToString(), dr.Item("UNITS").ToString(), dr.Item("LOAD_ID").ToString(), dr.Item("ORDER_TYPE").ToString())
 
                           results.Add(neword)
                       Next
                   End If
               End If
 
               OMSGrid.DataSource = results
               OMSGrid.DataBind()

This is grid pre-render code:

Protected Sub OMSGrid_PreRender(sender As Object, e As System.EventArgs) Handles OMSGrid.PreRender
    OMSGrid.Rebind()
 
    Dim grdIt() As GridItem = OMSGrid.MasterTableView.GetItems(GridItemType.Header)
    If grdIt.Length > 0 Then
        Dim headerItem As GridHeaderItem = CType(OMSGrid.MasterTableView.GetItems(GridItemType.Header)(0), GridHeaderItem)
        If Not headerItem.FindControl("headerChkbox") Is Nothing Then
            If OMSGrid.Items.Count > 0 Then
                CType(headerItem.FindControl("headerChkbox"), CheckBox).Checked = OMSGrid.SelectedItems.Count = OMSGrid.Items.Count
            End If
        End If
    End If
End Sub


0
Maria Ilieva
Telerik team
answered on 21 Dec 2012, 11:26 AM
Hello,

I suppose that on checkbook checked some java script error appear on the page that causes the problematic behavior as the code works properly on my end. Could you please see the response in browser console and verify if any errors appear on the page?

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
VITALY
Top achievements
Rank 1
answered on 21 Dec 2012, 01:40 PM
Maria,

There is no any error. You click, and the master table view disappears: you see only empty box with nothing inside.We run it in development environment and no run-time errors, no any messages - just empty box.

Thank you,

Vitaly
0
Daniel
Telerik team
answered on 26 Dec 2012, 09:24 AM
Hello Vitaly,

Most probably the problem is caused by a databinding issue. I would recommend that you take advantage of the advanced data-binding capabilities offered by RadGrid. This will help you avoid similar problems in the future.
For your convenience I have created a simple runnable demo (website), based on your code. Give it a try and then let me know whether this approach is suitable for you.
For more information, please examine the following links:
Simple Data-binding
Advanced Data-binding (using NeedDataSource event)

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
VITALY
Top achievements
Rank 1
answered on 02 Jan 2013, 10:31 PM
Dear Daniel,

When I'm checking/unchecking checkbox in grid template column it suppose to select/unselect corresponding row. However, if you move binding code to NeedDataSource event, checking/unchecking any checkbox is triggering NeedDataSource event, which in turn wiping out checkbox selection, unchecking all rows. And this is happening even when I'm using 2010 controls.

So I cannot use your suggestion to move binding code to NeedDataSource event.

This is my assignment briefly: 1. Load data in a grid. 2. Select some rows 3. Move selected rows to another grid 4. Repeat steps 2 and 3.

Hope this will clarify the issue.


Regards,

Vitaly


0
Daniel
Telerik team
answered on 07 Jan 2013, 11:21 AM
Hello Vitaly,

I'm unable to reproduce this problem. Could you please download the attached website and confirm if you experience such issues?
You just have to add a BIN folder with the corresponding assemblies and then open the folder as website in Visual Studio.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 30 Oct 2013, 03:13 PM
I encountered this same issue after an upgrade from an old 2010 version to the lastest 2013 version!  I have a checkbox column with AutoPostBack=true, and in the NeedsDataSource handler after clicking the checkbox, the MasterTableView does not seem to be properly populated.  I've tried with ViewState both enabled and disabled on the RadGrid control.  How did you end up resolving this?
0
Daniel
Telerik team
answered on 04 Nov 2013, 01:03 PM
Hello Cory,

Can you please let me know how could I reproduce the issue locally? This will help me provide a suitable workaround if there is such problem.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 17 Jan 2014, 05:29 PM
I'm just picking up this issue again and it has become urgent.  Here is our scenario so you can research further:

We have a RadGrid that uses the NeedDataSource event for binding.  There's a GridTemplateColumn containing an asp:Checkbox which has AutoPostBack set to True.  When the checkbox is checked and the page posts via AJAX, within the NeedDataSource handler there is code that iterates through the MasterTableView.Items collection.  In the previous version of the control we were using (2010.2.929.35), that collection was fully populated with the current state of the grid.  In the current version we're using (2013.2.717.45), it is empty, and as an end result, our checkbox's checked state is never saved.  I verified that there is no code in the codebehind that is triggering an early Rebind or anything like that.  If I had to guess, I know you guys have made some changes for the sake of performance in which certain objects are not loaded unless explicitly requested...maybe MasterTableView.Items is one of those(?).

Here is our grid:
<telerik:RadGrid ID="rgESList" runat="server" Width="100%" EnableEmbeddedSkins="false"
                Skin="VPM_Inside_Panel" AutoGenerateColumns="False" EnableViewState="false" OnNeedDataSource="rgESList_NeedDataSource"
                PagerStyle-Mode="NumericPages" AllowPaging="true" PageSize="20" AllowSorting="true" onrowdrop="rgESListReorderGrid_Main_RowDrop">
                <MasterTableView RetrieveAllDataFields="true" Width="100%" TableLayout="Fixed" AllowSorting="true" ClientDataKeyNames="ESSectionRequired,ESSectionTitle, ESSectionText, ESSectionOptional">
                    <Columns>
 
                        <telerik:GridBoundColumn UniqueName="Name" DataField="ESSectionTitle" HeaderText="*Section Name">
                        </telerik:GridBoundColumn>
                         
                      <telerik:GridTemplateColumn InitializeTemplatesFirst="true" UniqueName="CheckBoxTemplateColumn" >
                      <HeaderTemplate>Optional</HeaderTemplate
                      <ItemTemplate>
                      <asp:CheckBox runat="server" ID="ESSectionOptional" AutoPostBack="True" Checked='<%# Eval("ESSectionOptional") %>' />
                      </ItemTemplate>
                       </telerik:GridTemplateColumn>
 
                    </Columns>
                </MasterTableView>
                <ClientSettings AllowRowsDragDrop="true">
                    <ClientEvents OnRowClick="function(s,e) { GetInfoFromGridRowOnSelect(s, e); RefreshAdHocNotification(e.getDataKeyValue('ESSectionRequired'), e.getDataKeyValue('ESSectionTitle'), e.getDataKeyValue('ESSectionText'),e.getDataKeyValue('ESSectionOptional')); }" />
                    <Scrolling ScrollHeight="250px" AllowScroll="true" UseStaticHeaders="true" />
                    <Selecting AllowRowSelect="true" />
                </ClientSettings>
            </telerik:RadGrid>

This section of the page is wrapped with an UpdatePanel...
<asp:UpdatePanel ID="pnlMF" UpdateMode="Conditional" runat="server">
...
</asp:UpdatePanel>

...and here is the portion of the NeedDataSource handler that looks for the Checkbox controls.  I know it's not great code :), but it worked...
public void rgESList_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
 
            bool updaterequired = false;
 
            ArrayList optionalchecks = new ArrayList();
            foreach (GridDataItem dataItem in rgESList.MasterTableView.Items)
            {
                if ((dataItem.FindControl("ESSectionOptional") as CheckBox).Checked)
                {
                    optionalchecks.Add(true);
                    updaterequired = true;
                }
 
...

Are there any properties on the RadGrid or on the GridTemplateControl that would change the behavior?  As I mentioned, we have tried turning on ViewState for the grid, as well as a couple of other things to no avail.
0
Daniel
Telerik team
answered on 23 Jan 2014, 01:43 PM
Hello Cory,

I'm afraid it is very hard to track every single change to the master table view for the past three years. That said, I think I'm missing something because I'm unable to reproduce the problem on my end. Attached to this post is a simple runnable website which you can test at your side.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 23 Jan 2014, 08:37 PM
Hi Daniel,

I took your example and modified it to come up with as close to our production version as possible, but the forum uploader wouldn't let me attach the .zip even when I renamed it.  Anywah, I think the main difference may be the fact that EnableViewState on my grid is false.  Keep in mind that in the version of our page that works, the state of the CheckBoxes is saved on each check/uncheck of each CheckBox, and that save no longer works.  To be more specific:  When I run the new version of my page (with v2013 Telerik referenced), checking a checkbox triggers a postback as expected (due to AutoPostBack=true on the checkbox), but NeedsDataSource is never triggered (because the checkbox is not wired up to rebind the grid?).  When I run the old version of the page (with v2010 Telerik referenced), despite the fact that Rebind() doesn't explicitly seem to be called, it does still hit NeedsDataSource for some reason.  When I debug and look at the EventArgs of NeedsDataSource, the RebindReason is PostbackViewStateNotPersisted.

So is that it?  Did having ViewState off used to be a reason to always implicitly trigger a rebind on postback, and it isn't any longer?  If so, what's the best way to handle that?  Can I override that default behavior via some property change on the grid, or do I somehow need to manually wire up the CheckBoxes so that their CheckedChanged event makes a manual call to Rebind() during its postback, like you do with the Button's Click event handler?  How do I do that for CheckBox controls that live inside an ItemTemplate?
0
Daniel
Telerik team
answered on 29 Jan 2014, 11:53 AM
Hello Cory,

I believe I may have found the problem. I need some time to ensure I'm on the right track.
Will keep you posted when I have more information. Feel free to ping the thread anytime.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 12 Feb 2014, 07:31 PM
Daniel, you said you were potentially chasing a solution for this issue a couple of weeks ago - can you provide an update?
0
Daniel
Telerik team
answered on 19 Feb 2014, 03:37 PM
Hello Cory,

We will do our best to address this for the next service pack release. There is a considerable risk of introducing breaking changes so our developers will have to be extra careful.
I will update the thread when I have more information on this issue.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 19 Feb 2014, 03:41 PM
I appreciate it.  However, this represents an unresolved bug in our codebase for which we need at least a workaround right now.  Can you please provide at least some way for us to hack around the problem for the time being?
0
Daniel
Telerik team
answered on 25 Feb 2014, 04:02 PM
Hello Cory,

We spent a lot of time investigating the problem. Indeed, if you invoke Rebind in this case, NeedDataSource won't be fired. I can provide a workaround for this case - set RadGrid.DataSource = null (before calling Rebind) to force the control to rebind.
I'm afraid however that I'm not able to fully understand or reproduce the other problem where you click on the checkboxes. I would ask that you open a support ticket with a simple runnable demo attached so that we can investigate it again. Also please add a reference to this forum post so that we can keep track of the ticket history.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Cory Seaman
Top achievements
Rank 1
answered on 25 Feb 2014, 07:48 PM
Thank you Daniel.  The checkbox issue I described appears to be directly caused by the Rebind problem you described, so there's no need to address that further if the Rebind/NeedDataSource issue will be fixed in an upcoming release.  Can you update this thread with a notification when that version is released?
0
Daniel
Telerik team
answered on 28 Feb 2014, 12:47 PM
Hello Cory,

Our conclusion is that fixing this issue may break the whole control's ViewState. If the workaround is not working for you or if you want it to log it anyway you can submit a bug report here:
Feedback portal
Please excuse us for any inconvenience caused.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
VITALY
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
VITALY
Top achievements
Rank 1
Daniel
Telerik team
Cory Seaman
Top achievements
Rank 1
Share this question
or