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

radGridView Total and limit value

1 Answer 446 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jesús
Top achievements
Rank 2
Jesús asked on 14 Feb 2013, 08:39 PM
Hi

I have this scene, one mask edit with integer limit quantity. One radgrid for introducing any number of row. 3 Columns. (2 dropdown, one decimal column)

our users can write data if the quantity  is less than limit quantity. If the summatory of the grid and the current row is over the limit i want cancel this new line. How can do this?

In this grid, too, we have 2 raddropdown list editor, for the autocomplete mode. But we want to limit to the existing data. If the data don't not exist the user can't leave the current cell. It is possible? How?

tx in advanced.

Jesús.

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 19 Feb 2013, 02:14 PM
Hi Jesus,

Thank you for writing.

1) You can cancel adding a new row in RadGridView by using the
UserAddingRow event handler:
void gridView_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
{
    if (e.Rows.Length > 0 && e.Rows[0] is GridViewNewRowInfo)
    {
        GridViewNewRowInfo rowInfo = e.Rows[0] as GridViewNewRowInfo;
        if (rowInfo.Cells["id"].Value == null && rowInfo.Cells["number"].Value.ToString() == "111")
        {
            e.Cancel = true;
        }
    }
}

2) You can use CellValidating event to implement this functionality:
void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
{
    GridViewDataColumn column = e.Column as GridViewDataColumn;
    if (e.Row is GridViewDataRowInfo && column != null && column.Name == "CategoryName")
    {
        if (string.IsNullOrEmpty((string)e.Value) || ((string)e.Value).Trim() == string.Empty)
        {
            e.Cancel = true;
            ((GridViewDataRowInfo)e.Row).ErrorText = "Validation error!";
        }
        else
        {
            ((GridViewDataRowInfo)e.Row).ErrorText = string.Empty;
        }
    }
}

More information about this topic you can find in our online documentation.

I hope this helps.

Regards,
Julian Benkov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
GridView
Asked by
Jesús
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
Share this question
or