12 Answers, 1 is accepted
You can achieve the described scenario with adding a command that responds on the DataGrid CellTap command and tell the datagrid that you want it to go in edit mode for this cell. I have attached an example how this could be achieved for TextColumn and NumericalColumn.
Please take a look at the attached project and let me know if you have any other questions.
Regards,
Didi
Progress Telerik
I was a bit to early out.
I also have ValidateCommand on the same Grid. After the Celltap was introduces
namespace
TelerikXamarinApp1.Portable.Commands
{
public
class
ValidateEditUserCommand : DataGridCommand
{
public
ValidateEditUserCommand()
{
Id = DataGridCommandId.ValidateCell;
}
public
override
bool
CanExecute(
object
parameter)
{
return
true
;
}
public
override
void
Execute(
object
parameter)
{
ValidateCellContext validateContext = (ValidateCellContext)parameter;
if
(validateContext.Errors.Count==0)
{
FlightViewModel viewModel = (FlightViewModel) ((NavigationPage)
Application.Current.MainPage).CurrentPage.BindingContext;
viewModel.UpdateCalculation();
}
base
.Execute(parameter);
}
}
}
dataGridFuel.Commands.Add(
new
ValidateEditUserCommand());
dataGridFuel.Commands.Add(
new
CellTapUserCommand(
this
.dataGridFuel));
Best regards
Ole
Thank you for the provided code.
I have modified the attached sample and included the ValidationCommand on it. For the exact implementation of the validation command in RadDataGrid control please refer to the Country.cs file and ValidateCellCommand.cs file from the attached project.
We're working on extending the DataGrid documentation with more information on the separate commands including the validation command.
I hope I could help.
Regards,
Didi
Progress Telerik
Hi,
The example did not trigger the validation. I used your project I just replaced you telerik nuget components with trial ones with same version. Could there be a difference in trial and non trial.
I have tested the attached project with the trial version of Telerik UI for Xamarin controls and on my side the validation command is triggered as expected. Please take a look at the attached video. Regarding trial and non trial version of our suite I can confirm that there is no difference between the trial and licensed version of the controls, only a trial message pops up when referencing the trial nuget packages.
Let me know if you have any additional questions.
Regards,
Didi
Progress Telerik
This is a standard validation mechanism using INotifyDataErrorInfo interface. In the context of RadDataGrid, the validation is triggered when the cell is in edit mode and the end user tries to commit the entered value. It is not possible to exit the editing mode until the validation rule of the data item is met.
Could you elaborate more on what you mean with navigating between cells in one row? I am asking as in general this is not related to the editing functionality of the control.
Regards,
Didi
Progress Telerik
Scenario:
I edit a country name to more than 15 chars, then I click on the population column in the same row.
Then this happened:
HasErrors is true, the focus shifts to the populations field, no red warning bar.
I would have exspected:
HasError is true , focus still on name column , red warning bar displayed.
I have tested the described scenario and on my side it works as expected. I have recorded a video, so you could take a look at it. Please note that this is a sample project that shows how the validation command could be implemented and you could customize it according to your specific setup.
May I ask you to modify the attached sample regarding your setup and send it back to me? In this case I could research it further. Also note that you should open a support ticket and attach the project there because in the forum only image attachments are allowed.
Regards,
Didi
Progress Telerik
I am using the demo project only.
I can see that you changed the project , country.cs line 27 . from > 15 to < 15.
Fixing that so hasErrors is false as a starting point for all rows.
Then start by editing Mozambique to have a length > 15, then imideately tap to edit the population column in the same row.
No other steps needed.
This scenario was not shown in the video.
Then this happened:
HasErrors is true, the focus shifts to the populations field, no red warning bar.
I would have exspected:
HasError is true , focus still on name column , red warning bar displayed.
I am using IOS.
Best Regards
Ole
As the initial request was to change the default state of the CellTap command and execute BeginEdit command, this lead to changes in the default logic cycle how the DataGrid commands work. In order to achieve more complex scenario or changing the default command a custom logic should be implemented. So, I have modified the attached demo project to cover the expected scenario. Please have in mind that this is a sample implementation you could use a starting point and further extend it if needed. Additionally, I cannot guarantee it covers all the use cases you might have.
I hope I was of help.
Regards,
Didi
Progress Telerik