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

Persistance Framework Radgird Removed Column Issue

7 Answers 114 Views
Persistence Framework
This is a migrated thread and some comments may be shown as answers.
Nanthakumar
Top achievements
Rank 1
Nanthakumar asked on 10 Nov 2014, 08:17 PM
 Hi,

Im storing the radgrid Persistance xml format string values into my Database table.
if i remove any static column from radgrid and datatable  then load  the already saved persistance values into radgrid its throwing error like 
DataField Column is not found in Datasource .

Please give me solution as soon as possible


Thanks
Nanthakumar.t

7 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 13 Nov 2014, 12:55 PM
Hi Nanthakumar,

I am afraid I was unable to replicate the issue locally. I prepared a small smample and I save the state in an xml on the server. After I save the state and remove any of the column from the DataTable and RadGrid columns collection no error is thrown. Could you please give the attached sample a try and let me know how it differs from your real setup? I would appreciate if you can provide a small runnable sample in order to investigate it further.

Regards,
Kostadin
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
Nanthakumar
Top achievements
Rank 1
answered on 17 Nov 2014, 07:38 AM
HI,

I have tried your sample file stile same issue there.. 

Steps to reproduce Issue 

1.run your sample application
2. Click Sort by  Column4 and Save State and stop application
3.Now Remove Column4 in Grid andalso Comment out the column4 in  Code Behind 

ASPX 

<telerik:RadGrid ID="RadGrid1" runat="server" EnableHeaderContextMenu="true" OnNeedDataSource="RadGrid1_NeedDataSource"  AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true">
         <HeaderContextMenu>
         </HeaderContextMenu>
            <ClientSettings>
                <Resizing AllowColumnResize="true" />
                <Selecting AllowRowSelect="true" />
             </ClientSettings>
            <MasterTableView CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridBoundColumn DataField="Column1"  HeaderText="Column1"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Column2"  HeaderText="Column2"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Column3"  HeaderText="Column3"></telerik:GridBoundColumn>
                    <%--<telerik:GridBoundColumn DataField="Column4"  HeaderText="Column4"></telerik:GridBoundColumn>--%>
                </Columns>
            </MasterTableView>
            <FilterMenu EnableEmbeddedSkins="False">
                    </FilterMenu>
                     <HeaderContextMenu EnableEmbeddedSkins="true" >
                    </HeaderContextMenu>
        </telerik:RadGrid>
Code Behind :
 DataTable table = new DataTable();

            table.Columns.Add("Column1");
            table.Columns.Add("Column2");
            table.Columns.Add("Column3");
            //table.Columns.Add("Column4");

            for (int i = 0; i < 20; i++)
            {
                table.Rows.Add("Col1Row" + i, "Col2Row" + i, "Col3Row" + i);//, "Col4Row" + i);
            }

            return table;
 4. Again run application and click load state button it will throw error  "Column4 is neither a DataColumn nor a DataRelation for table  " and attached error file  due to i cant post my tested file in this post 






0
Nanthakumar
Top achievements
Rank 1
answered on 17 Nov 2014, 07:41 AM
XML String 

<?xml version="1.0"?>
<ArrayOfRadControlState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <RadControlState>
    <ControlSettings />
    <UniqueId>Telerik.Web.UI_PersistanceManager_CustomSettings</UniqueId>
  </RadControlState>
  <RadControlState>
    <ControlSettings>
      <ControlSetting>
        <Name>CurrentPageIndex</Name>
        <Value Type="System.Int32">
          <int>0</int>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>EditIndexes</Name>
        <Value Type="Telerik.Web.UI.GridIndexCollection">
          <GridIndexCollection>
            <Data />
          </GridIndexCollection>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>PageSize</Name>
        <Value Type="System.Int32">
          <int>10</int>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>SelectedCellIndexes</Name>
        <Value Type="Telerik.Web.UI.GridIndexCollection">
          <GridIndexCollection>
            <Data />
          </GridIndexCollection>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>SelectedIndexes</Name>
        <Value Type="Telerik.Web.UI.GridIndexCollection">
          <GridIndexCollection>
            <Data />
          </GridIndexCollection>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>Width</Name>
        <Value Type="System.Web.UI.WebControls.Unit">
          <Unit />
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.Width</Name>
        <Value Type="System.Web.UI.WebControls.Unit">
          <Unit />
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.FilterExpression</Name>
        <Value Type="System.String">
          <string />
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.PageSize</Name>
        <Value Type="System.Int32">
          <int>10</int>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.ColumnSettings</Name>
        <Value Type="System.Collections.Generic.List`1[[Telerik.Web.UI.GridTableView+PersistableColumnSetting, Telerik.Web.UI, Version=2014.1.403.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4]]">
          <ArrayOfPersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>ExpandColumn</UniqueName>
              <Visible>true</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>-1</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width>20px</Width>
            </PersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>RowIndicator</UniqueName>
              <Visible>false</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>-1</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width>20px</Width>
            </PersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>Column1</UniqueName>
              <Visible>true</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>2</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width />
            </PersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>Column2</UniqueName>
              <Visible>true</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>3</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width />
            </PersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>Column3</UniqueName>
              <Visible>true</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>4</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width />
            </PersistableColumnSetting>
            <PersistableColumnSetting>
              <UniqueName>Column4</UniqueName>
              <Visible>true</Visible>
              <Display>true</Display>
              <SortExpression />
              <GroupByExpression />
              <OrderIndex>5</OrderIndex>
              <CurrentFilterFunction>NoFilter</CurrentFilterFunction>
              <CurrentFilterValue />
              <AndCurrentFilterFunction>NoFilter</AndCurrentFilterFunction>
              <AndCurrentFilterValue />
              <Width />
            </PersistableColumnSetting>
          </ArrayOfPersistableColumnSetting>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.SortExpressions</Name>
        <Value Type="Telerik.Web.UI.GridSortExpressionCollection">
          <ArrayOfGridSortExpression>
            <GridSortExpression>
              <FieldName>Column4</FieldName>
            </GridSortExpression>
          </ArrayOfGridSortExpression>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.GroupByExpressions</Name>
        <Value Type="Telerik.Web.UI.GridGroupByExpressionCollection">
          <ArrayOfGridGroupByExpression />
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.CurrentPageIndex</Name>
        <Value Type="System.Int32">
          <int>0</int>
        </Value>
      </ControlSetting>
      <ControlSetting>
        <Name>MasterTableView.IsItemInserted</Name>
        <Value Type="System.Boolean">
          <boolean>false</boolean>
        </Value>
      </ControlSetting>
    </ControlSettings>
    <UniqueId>ctl00$MainContent$RadGrid1</UniqueId>
    <UniqueKey />
  </RadControlState>
</ArrayOfRadControlState>
0
Kostadin
Telerik team
answered on 20 Nov 2014, 08:20 AM
Hi Nanthakumar,

I was able to replicate the issue on my side as well. The reason is that the sort expression is create and since the column is removed from the datasource it throws an error. I will forward this issue to one of our developer for further investigation and meanwhile you can track the progress in our Ideas&Feedback portal

Regards,
Kostadin
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
Bryan
Top achievements
Rank 1
answered on 14 Jun 2016, 11:13 PM

was this every fixed or a solution found? 

I am saving the cookie to databases on dynamic grids and would like a way to just ignore sorted columns that have been removed

0
Kostadin
Telerik team
answered on 17 Jun 2016, 01:10 PM
Hello Bryan,

This issue will not be fixed since this is an expected behavior. Here is the answer provided in the feedback item from one of our team members:
"We have investigated the case thoroughly. This is not a bug, but an expected behavior. You need to save a new state after introducing major changes like these."

Regards,
Kostadin
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Bryan
Top achievements
Rank 1
answered on 20 Jun 2016, 02:42 PM

I wrote a work around using the following to remove the sort expression if the column no longer exists before rebinding the grid

 

 Private Sub CheckForDeletedSortedColumnAndRemoveSortExpression()
        Dim sortString As String = dgLog.MasterTableView.SortExpressions.GetSortString()
        If Not IsNothing(sortString) Then
            Dim sortExpression As GridSortExpression = dgLog.MasterTableView.SortExpressions.GetExpression(sortString)
            Dim gridColumn As GridColumn = dgLog.MasterTableView.Columns.FindByUniqueNameSafe(sortExpression.FieldName)
            If IsNothing(gridColumn) Then
                dgLog.MasterTableView.SortExpressions.RemoveSortExpression(sortExpression)
            End If
        End If
    End Sub

Tags
Persistence Framework
Asked by
Nanthakumar
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Nanthakumar
Top achievements
Rank 1
Bryan
Top achievements
Rank 1
Share this question
or