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

In Response to Thread: Breaking change: Hidden column cell text is not persisted in ViewState

3 Answers 10 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 12 Sep 2014, 04:41 PM
That is a terrible decision on your part. Breaking functionality for such a ridiculous concept of 'opimization'..

In large part, the hidden fields and values are what people WANT to persist in the viewstate.. They are usually ID fields.. 

ReadOnly, Display, and Visible ... which of these properties should NOT be removing labels and textboxes from the default EditTemplate?? The answer is: the ONLY that Telerik uses to do just that 'ReadOnly'.. 

What sort of counter-initative developers are you guys?.. people actually have to add special settings to their controls to have them behave the intuitive way?.. 

3 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 1
answered on 12 Sep 2014, 05:37 PM
ahhh.. nevermind.. I see you created a way to keep that data persistent using the DataKey attribute on the MasterView..
So It would seem I don't need to include the bound ID properties in the template..

I'm still not sure why yall think flagging a column as ReadOnly should remove it from being read on the EditTemplate by default...

well.. that a discussion for another time.. everything is functioning properly.
0
Konstantin Dikov
Telerik team
answered on 16 Sep 2014, 05:32 PM
Hello Brett,

First, let me start by saying that setting the Visible property to false and not persisting the values for the columns is the standard GridView behavior. You could test this with the following example:
<asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false"
    OnRowDataBound="GridView1_RowDataBound">
    <Columns>
        <asp:BoundField DataField="ID" Visible="false" />
        <asp:BoundField DataField="FirstName" />
    </Columns>
</asp:GridView>

And the code-behind:
protected void Page_Load(object sender, EventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("FirstName", typeof(string));
    for (int i = 0; i < 2; i++)
    {
        table.Rows.Add(i, "FirstName" + i);
    }
 
    GridView1.DataSource = table;
    GridView1.DataBind();
}
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        string id = e.Row.Cells[0].Text;
    }
}

The fact that columns with Visible property set to false were persisting values in RadGrid was leading to unnecessary performance issues and was not intuitive for users familiar with the standard controls, which was a major factor for the made decision for introducing such breaking change. With standard GridView, the only way for persisting values from such hidden column was to set the data fields in the DataKeyNames collection or to use custom CSS for hiding those columns. RadGrid exposes a Display property, which hides the columns, but still keeps the values available.

Generally, we always recommend that the DataKeyNames collection is used for retrieving values, which should not be displayed in grid.

Finally, please note that we are doing our best to avoid introducing any breaking changes, but sometimes, in order to improve the product, they are necessary.


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
Brett
Top achievements
Rank 1
answered on 16 Sep 2014, 07:29 PM
Perhaps I'm just noticing these quirks because I'm evaluating your controls without customizing the template sections to the extent I would with asp.net controls. That is, when I wasn't using System.ComponentModel Attributes on my objects to define all of that meta data on my classes and properties.  Of course, this is all back when I used to use server controls.. 

Normally, I would customize the ItemTemplate, EditTemplate, and InsertTemplate and put asp:hiddenfield controls that use eval or bind expressions depending on the context. Thus, using visible on the markup was never a consideration (or perhaps a very early stage). When I mean in the markup, I mean I'm sure I've set the visibility of a control to false in the code-behind.. but again, without much consideration whether or not the data needed to be persistent, because I used a specific server control for hidden fields.


















Tags
Grid
Asked by
Brett
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or