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

Restricting negative and decimal numbers

5 Answers 296 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Venkatesh
Top achievements
Rank 1
Venkatesh asked on 30 Aug 2014, 02:38 PM
Hi,

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

Regards,
Venkatesh Tata.

5 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 01 Sep 2014, 08:31 AM
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.

 
0
Venkatesh
Top achievements
Rank 1
answered on 03 Sep 2014, 05:46 AM
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.
0
Accepted
Radoslav
Telerik team
answered on 04 Sep 2014, 08:18 AM
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.

 
0
Venkatesh
Top achievements
Rank 1
answered on 23 Sep 2014, 07:34 AM
Hi Radoslav,

Thanks for your answer. Its working for me.

Regards,
Venkatesh.
0
Sonya
Top achievements
Rank 1
answered on 05 Oct 2014, 03:45 PM
Hi,
thanks for your help. It worked for me too.




real estate agent
assistant jobs
Tags
General Discussions
Asked by
Venkatesh
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Venkatesh
Top achievements
Rank 1
Sonya
Top achievements
Rank 1
Share this question
or