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

Allow integer only in edit mode

6 Answers 246 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lewis
Top achievements
Rank 1
Lewis asked on 17 Jan 2012, 03:21 PM
I use the following code to restrict edit to integer only. It only works when I edit a row first time. Whenever I keep clicking other rows it will turn back to numeric box again and allowing digits. What should I do to prevent this happening? I notice that after first clicking the grid will use column editor different from the one I designated on the page. It looks like default one. That's the reason I lost the integer constrain. How could I fix this?

 <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor3" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox2" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>

Thanks
Lewis

6 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 18 Jan 2012, 11:25 AM
Hi,

 Can you specify how you place the rows in edit mode and do you use multirow editing? Normally once you have specified the column markup it should be preserved on postback. Can you also post the definition of the column and any relevant code behind.

Regards,
Marin
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
Lewis
Top achievements
Rank 1
answered on 18 Jan 2012, 01:43 PM
Thanks for the feedback. Here is the full markup code. I made some modification from the demo code.

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="False"
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnItemUpdated="RadGrid1_ItemUpdated"
        OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="ID"
            DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
                <telerik:GridDropDownColumn DataField="col1" DataSourceID="SqlDataSource2"
                    HeaderText="col1" ListTextField="TypeName" ListValueField="TypeIndex" UniqueName="col1"
                    ColumnEditorID="GridDropDownColumnEditor1">
                </telerik:GridDropDownColumn>
                <telerik:GridNumericColumn DataField="col2" HeaderText="col2"
                    UniqueName="col2" ColumnEditorID="GridNumericColumnEditor2">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col3" HeaderText="col3" UniqueName="col3"
                    ColumnEditorID="GridNumericColumnEditor3">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col4" HeaderText="col4"
                    UniqueName="col4" ColumnEditorID="GridNumericColumnEditor4">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col5" HeaderText="col5" UniqueName="col5"
                    ColumnEditorID="GridNumericColumnEditor5">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col6" HeaderText="col6" UniqueName="col6"
                    ColumnEditorID="GridNumericColumnEditor6">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col7" HeaderText="col7" UniqueName="col7"
                    ColumnEditorID="GridNumericColumnEditor7">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="col8" HeaderText="col8" UniqueName="col8"
                    ColumnEditorID="GridNumericColumnEditor8">
                </telerik:GridNumericColumn>
                <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings ColumnNumber="8" CaptionDataField="GradeLevel" CaptionFormatString="Edit properties of record {0}"
                InsertCaption="New Record">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                    Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert record" UpdateText="Update record"
                    UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowClick="RowDblClick" OnGridCreated="gridCreated" />
        </ClientSettings>
    </telerik:RadGrid>
    <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server"
        DropDownStyle-Width="50px" />
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor2" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox1" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0" GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor3" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox2" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor4" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox3" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor5" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox4" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor6" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox5" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor7" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox6" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0"  GroupSeparator="" DecimalSeparator=" " />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor8" runat="server" NumericTextBox-Width="40px">
        <NumericTextBox ID="NumericTextBox7" DataType="System.Int32" runat="Server">
            <NumberFormat AllowRounding="true" DecimalDigits="0" GroupSeparator="" DecimalSeparator=" "  />
        </NumericTextBox>
    </telerik:GridNumericColumnEditor>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
0
Marin
Telerik team
answered on 20 Jan 2012, 11:38 AM
Hi Lewis,

 The markup for the grid looks fine. Can you also specify the client-side code for the RowClick and the GridCreated events or whether your code is based on some of our existing demos.

Kind regards,
Marin
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
Lewis
Top achievements
Rank 1
answered on 20 Jan 2012, 03:55 PM
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            <!--
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }

            function gridCreated(sender, args) {
            }
            -->
        </script>
    </telerik:RadCodeBlock>
0
Marin
Telerik team
answered on 23 Jan 2012, 06:34 PM
Hello Lewis,

 I was able to reproduce the problem on our side. It is logged in our system and forwarded for further investigation.

Thank you for reporting it.

All the best,
Marin
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
Marin
Telerik team
answered on 24 Jan 2012, 09:58 AM
Hello,

 We investigated the issue and this proves to be a design limitation for some of the column editors that apply other settings than just styles of the controls. Another option is to set the desired properties from code behind after the respective control of the editor is created (e.g. in ItemDataBound event).

All the best,
Marin
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
Tags
Grid
Asked by
Lewis
Top achievements
Rank 1
Answers by
Marin
Telerik team
Lewis
Top achievements
Rank 1
Share this question
or