We are using the GridViewMaskedInputColumn in RadGridView with MaskType="Numeric".
The binded value is type of nullable integer, so is there any method to accept empty or a numeric value in the gridview column.
Update: it is supported by default, I have checked a different column.
But my question has a change, how to avoid default value 0 on cell edit.
Regards,
Reyas Mohammed
The binded value is type of nullable integer, so is there any method to accept empty or a numeric value in the gridview column.
Update: it is supported by default, I have checked a different column.
But my question has a change, how to avoid default value 0 on cell edit.
Regards,
Reyas Mohammed
5 Answers, 1 is accepted
0
Hi,
I am not sure what default value you will expect instead of zero.
Generally you can avoid committing zeroes by subscribing to the CellEditEnded event. During this event you can check if the new data is 0 and if it is, you can apply your own custom logic there. More information about the edit events can be found at the following link in our online documentation.
For your convenience, i have attached a sample project demonstrating this solution.
If I have somehow misunderstood you and your requirement is different, would you please explain it in more details?
Regards,
Hristo
Telerik
I am not sure what default value you will expect instead of zero.
Generally you can avoid committing zeroes by subscribing to the CellEditEnded event. During this event you can check if the new data is 0 and if it is, you can apply your own custom logic there. More information about the edit events can be found at the following link in our online documentation.
For your convenience, i have attached a sample project demonstrating this solution.
If I have somehow misunderstood you and your requirement is different, would you please explain it in more details?
Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Reyas
Top achievements
Rank 2
answered on 24 Jan 2014, 03:54 PM
Hello Hristo,
Thank you for the response.
I will explain the problem in detail.
I am using radgridview, and the columns are bind to observable collection of entityframework auto generated class.
There are certain properties in class which are nullable integers (because they are nullable in database).
Everything work proper. But when I click on the column which is of type nullable int (?int) in the editmode, it adds 0.
Which is not desired. Hope you got my issue.
Regards,
Reyas Mohammed
Thank you for the response.
I will explain the problem in detail.
I am using radgridview, and the columns are bind to observable collection of entityframework auto generated class.
There are certain properties in class which are nullable integers (because they are nullable in database).
Everything work proper. But when I click on the column which is of type nullable int (?int) in the editmode, it adds 0.
Which is not desired. Hope you got my issue.
Regards,
Reyas Mohammed
0

Reyas
Top achievements
Rank 2
answered on 24 Jan 2014, 04:22 PM
I have modified your sample to showcase the issue I am facing.
But couldn't attach it, So I am posting the code snippet I have changed.
I have modified the StadiumCapacity to nullable integer, then removed the cell edit end event from code behind.
And in xaml with radgrid I have enable new row position.
When I am running the app, I am able to add new rows.
And if I dont click or focus(using keyboard) on the Stadium capacity column, the data will be empty.
But if I click on it, it sets as 0.
Regards,
Reyas Mohammed
But couldn't attach it, So I am posting the code snippet I have changed.
I have modified the StadiumCapacity to nullable integer, then removed the cell edit end event from code behind.
And in xaml with radgrid I have enable new row position.
public
int
? StadiumCapacity
{
get
{
return
_stadiumCapacity; }
set
{
if
(value != _stadiumCapacity)
{
_stadiumCapacity = value;
OnPropertyChanged(
"StadiumCapacity"
);
}
}
}
When I am running the app, I am able to add new rows.
And if I dont click or focus(using keyboard) on the Stadium capacity column, the data will be empty.
But if I click on it, it sets as 0.
Regards,
Reyas Mohammed
0
Hello Reyas,
When you click on the cell, the default value is 0, because the GridViewMaskedInputColumn's mask type is numeric . There are two possible solutions to your issue:
The first one is to make changes in the setter of the property. Basically, you would have to check the value and if it is 0, to can change it to null during in the property's setter.
For example with the property StadiumCapacity you can use the following snippet:
The second solution is to change the GridViewMaskedInputColumn's mask type to different value, for example Standard.
Regards,
When you click on the cell, the default value is 0, because the GridViewMaskedInputColumn's mask type is numeric . There are two possible solutions to your issue:
The first one is to make changes in the setter of the property. Basically, you would have to check the value and if it is 0, to can change it to null during in the property's setter.
For example with the property StadiumCapacity you can use the following snippet:
public
int
? StadiumCapacity
{
get
{
return
stadiumCapacity; }
set
{
if
(value != stadiumCapacity)
{
if
(value==0)
{
stadiumCapacity =
null
;
OnPropertyChanged(
"StadiumCapacity"
);
return
;
}
stadiumCapacity = value;
OnPropertyChanged(
"StadiumCapacity"
);
}
}
}
The second solution is to change the GridViewMaskedInputColumn's mask type to different value, for example Standard.
Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Reyas
Top achievements
Rank 2
answered on 30 Jan 2014, 08:01 AM
Thank you for the post.
I will check.
I will check.