Restricting negative and decimal numbers

6 posts, 1 answers
  1. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 30 Aug 2014 Link to this post

    Hi,

    How to restrict negative numbers and decimals for some of the columns in radgrid.

    Regards,
    Venkatesh Tata.
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 01 Sep 2014 Link to this post

    Hello Venkatesh,

    Could you please elaborate a bit more on your scenario? How do you want to restrict negative numbers and decimals into the column. Do you want to hide them or mark them with different styles? If this is the case you can handle the ItemDataBound event and change the (e.item as GridDataItem)[ColumnUniqueName].Text property or (e.item as GridDataItem)[ColumnUniqueName]’s style if the value into the (e.Item as GridDataItem).DataItem for a column is negative or decimal.

    Looking forward for your reply.

    Regards,
    Radoslav
    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.

     
  3. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 03 Sep 2014 Link to this post

    Hi,

    My radgrid is having multiple columns with batch edit(cell) option. In that some of columns should accept negative numbers and some of them should not accept negative numbers.So,While editing the cell for some columns i need to restrict negative values. Is it possible by columns unique name or something else?

    Regards,
    Venkatesh.
  4. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 04 Sep 2014 Link to this post

    Hello Venkatesh,

    To achieve the desired functionality you can try adding a custom column editor to the column which needs to be non-negative and with decimal digits. For example:
    <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowSorting="True" AllowPaging="True" ShowFooter="true">
            <MasterTableView ShowGroupFooter="true" EditMode="Batch">
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" HeaderText="ID"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Item" HeaderText="Item" Aggregate="Count"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Date" HeaderText="Date"></telerik:GridBoundColumn>
                    <telerik:GridNumericColumn DataField="Num" ColumnEditorID="GridNumericColumnEditor1" HeaderText="NonNegative"></telerik:GridNumericColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server">
            <NumericTextBox MinValue="0" NumberFormat-DecimalDigits="0"></NumericTextBox>
        </telerik:GridNumericColumnEditor>

    Please give it try and let me know if it helps you.

    Looking forward for your reply.

    Regards,
    Radoslav
    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.

     
  5. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 23 Sep 2014 Link to this post

    Hi Radoslav,

    Thanks for your answer. Its working for me.

    Regards,
    Venkatesh.
  6. Sonya
    Sonya avatar
    1 posts
    Member since:
    Oct 2014

    Posted 05 Oct 2014 in reply to Radoslav Link to this post

    Hi,
    thanks for your help. It worked for me too.




    real estate agent
    assistant jobs
Back to Top