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

Change page size on grid with editable column not working

3 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendon
Top achievements
Rank 1
Brendon asked on 24 Sep 2013, 05:49 AM
Hi,

I have searched high and low for a solution to this problem, but haven't been able to find answer as yet.

I am trying to fix a bug in an existing application.  There is a grid with a column of text-boxes that the user can enter data into.  The column is made editable in the grid PreRender event.

Here is the code:

 
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
    <telerik:RadGrid ID="TGrid" runat="server" Visible="true" AllowPaging="true" AllowSorting="true"
        PageSize="20" ScrollHeight="100px" ViewStateMode="Enabled" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnPreRender="RadGrid1_PreRender" AutoGenerateColumns="false" AllowSelection="False"
        AllowMultiRowSelection="false" AllowMultiRowEdit="true" >
        <MasterTableView runat="server" HeaderStyle-Wrap="False" AllowCustomSorting="true"
            AllowMultiColumnSorting="false" RetrieveAllDataFields="false" EnableColumnsViewState="false"
            EditFormSettings-EditColumn-Visible="false" AdditionalDataFieldNames="Cow_ID"
            DataKeyNames="Cow_ID" EditMode="InPlace">
            <Columns>
                <telerik:GridBoundColumn DataField="Cow_ID" HeaderText="MiHub ID" DataType="System.Int32"
                    ReadOnly="true" HeaderStyle-Width="6em" />
                <telerik:GridBoundColumn DataField="COW_EID" HeaderText="Electronic ID" DataType="System.String"
                    ReadOnly="true" HeaderStyle-Width="12em" />
                <telerik:GridBoundColumn DataField="COW_LifeId" HeaderText="Birth ID" DataType="System.String"
                    ReadOnly="true" HeaderStyle-Width="8em" />
                <telerik:GridBoundColumn DataField="COW_VID" HeaderText="Current Visual ID" DataType="System.Int32"
                    ReadOnly="true" HeaderStyle-Width="8em" />
                <telerik:GridTemplateColumn DataField="COW_VID" HeaderText="New Visual ID" DataType="System.Int32"
                    ReadOnly="false" HeaderStyle-Width="15em">
                    <EditItemTemplate>
                        <telerik:RadNumericTextBox runat="server" ID="tbNewVisualID" SelectionOnFocus="SelectAll"
                            AutoPostBack="false" MinValue="0" MaxValue="999999">
                            <NumberFormat DecimalDigits="0" GroupSeparator="" />
                            <ClientEvents OnKeyPress="TelerikVisualIDKeyPress" OnValueChanged="TelerikValueChanged" />
                        </telerik:RadNumericTextBox>
                        <span class="errorText" style="display: none">*NOT UNIQUE*</span>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</div>


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
 
        var data = new List<object>();
        for (int i = 0; i < 1000; i++)
        {
            data.Add(new {Cow_Id = i, Cow_EID = i,cow_LifeId = i, Cow_VID = i});
        }
 
        TGrid.DataSource = data;
 
    }
 
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        foreach (GridItem item in TGrid.MasterTableView.Items)
        {
            if (item is GridEditableItem)
            {
                GridEditableItem editableItem = item as GridDataItem;
                editableItem.Edit = true;
            }
        }
        TGrid.Rebind();           
    }
}

Running the code shows the editable column correctly, however changing the page size doesn't work as expected.  Paging however seems to work fine.

If I comment out  TGrid.Rebind();, or editableItem.Edit = true; then changing the page size works as expected, but then the column is not editable.  Any thoughts?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Sep 2013, 07:03 AM
Hello,

I am not able to reproduce this issue with your code.

http://screencast.com/t/biRbtdg9F

Note :

As per your code you want only one column in editmode and this column is always in editmode.  Then please add this Textbox in normal mode.

By using this  way you can reduce one rebind call from the radgrid prerender event. As well as it also generate less viewstate. so it will give
better performance from serverside and clientside.


<telerik:GridTemplateColumn DataField="COW_VID" HeaderText="New Visual ID" DataType="System.Int32"
                        ReadOnly="false" HeaderStyle-Width="15em">
                        <ItemTemplate>
                            <telerik:RadNumericTextBox runat="server" ID="tbNewVisualID" SelectionOnFocus="SelectAll"
                                AutoPostBack="false" MinValue="0" MaxValue="999999">
                                <NumberFormat DecimalDigits="0" GroupSeparator="" />
                            </telerik:RadNumericTextBox>
                            <span class="errorText" style="display: none">*NOT UNIQUE*</span>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>


Let me know if any concern.

Thanks,
Jayesh Goyani
0
Brendon
Top achievements
Rank 1
answered on 24 Sep 2013, 09:58 PM
Hi,

Thanks for the fast response.  I have checked the version of Telerik we are using, and it seems that it isn't the latest version, the version we have is 2012.3.1308.40.  Is it possible to replicate the problem with this version?  Sorry, I should have mentioned this at the beginning.  I think this version is the latest our subscription allows us to use, I will check.

I'll try the updated Html and see how that goes.

Cheers,
Brendon.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Sep 2013, 10:32 AM
Hello,

As per my experience with this control there is not such type of issue in this control.

Can you upload your project using support ticket?


Thanks,
Jayesh Goyani

Tags
Grid
Asked by
Brendon
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Brendon
Top achievements
Rank 1
Share this question
or