11 Answers, 1 is accepted
Indeed, the documentation and the examples do not show a scenario on how to achieve the behavior. We have the tasked logged at our end so we will try to come up with such information as soon as possible. In the meantime, here is how you can create a custom command:
public
class
CellDoubleTapCommand : DataGridCommand
{
public
CellDoubleTapCommand()
{
this
.Id = DataGridCommandId.CellDoubleTap;
}
public
override
void
Execute(
object
parameter)
{
var context = parameter
as
DataGridCellInfo;
//perform some logic
this
.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellDoubleTap, parameter);
}
}
Eventually, you need to add this custom command to the Commands collection of the RadDataGrid. I have attached a sample for your reference. Please review it and update me whether it was useful.
Have a great rest of the week.
Regards,
Stefan Nenchev
Progress Telerik
Hi,
Is there any example of validating a cell ??
I can't find any either.
I have attached another example that shows how to implement the ValidateCell command. You can create a UI of your choice that will be used as a presenter for the errors if such are present. As noticed, the business class implements the INotifyDataErrorInfo in order to set up the validation.
I hope it will be helpful.
Regards,
Stefan Nenchev
Progress Telerik
Hi,
I think that the documentation and examples need some improvement in that field.
There is nothing about creating a new command or how to achieve a behaviour.
Regards,
Stavros
Undoubtedly, the documentation of the RadDataGrid is missing information on key features. Please excuse us for the inconvenience this might be causing you. We are currently working on adding different articles and, hopefully, we will have included different scenarios and detailed information on specific functionalities by the time the next official release - R2(scheduled for 16 May) - is available.
Your feedback is highly appreciated. In the meantime, if you are facing any issues or need some assistance, do not hesitate to contact us.
Regards,
Stefan Nenchev
Progress Telerik
You can simply declare the command:
public
class
BeginEditCommand : DataGridCommand
{
public
BeginEditCommand()
{
this
.Id = DataGridCommandId.BeginEdit;
}
public
override
void
Execute(
object
parameter)
{
var context = parameter
as
EditContext;
this
.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.BeginEdit, parameter);
}
}
And add it to the Commands collection of the RadDataGrid:
<
telerikDataGrid:RadDataGrid
x:Name
=
"DataGrid"
Grid.Row
=
"1"
UserEditMode
=
"Cell"
AutoGenerateColumns
=
"True"
ItemsSource
=
"{Binding Items}"
>
<
telerikDataGrid:RadDataGrid.Commands
>
<
localCommands:BeginEditCommand
/>
<
localCommands:CellDoubleTapCommand
/>
</
telerikDataGrid:RadDataGrid.Commands
>
<
telerikDataGrid:RadDataGrid.BindingContext
>
<
local:ViewModel
/>
</
telerikDataGrid:RadDataGrid.BindingContext
>
</
telerikDataGrid:RadDataGrid
>
I have attached another sample for your reference.
Regards,
Stefan Nenchev
Progress Telerik
Please take a look at the attached sample how to navigate to another page when the DataGrid CellTap Comand is executed.
I hope this could help.
Regards,
Didi
Progress Telerik
I have implemented a BeginEdit command and that works. When it fires, I get a parameter with a CellInfo object. That object refers to the first cell in the row where editing was enabled.
In my case, I need to get to the third cell in the same row which is a TextBlock and then manipulate the properties of the TextBlock. How can I get to the Text Block element?
<grid:DataGridTextColumn Header="Date " PropertyName="Timestamp" CanUserEdit="False" />
<grid:DataGridTextColumn Header="User" PropertyName="UserName" CanUserEdit="False"/>
<grid:DataGridTextColumn Header="Note" PropertyName="Text" CanUserEdit="True">
<grid:DataGridTextColumn.CellContentStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="WrapWholeWords"/>
</Style>
</grid:DataGridTextColumn.CellContentStyle>
</grid:DataGridTextColumn>
Regards
Andy
This forum thread is the general topic for Telerik UI for Xamarin.
The code you've shared does not appear to be for Xamarin.Forms (there is no Header property in Xamarin.Forms). Additionally, Xamarin.Forms does not have a TextBlock control. Therefore, I am assuming you are using UWP and the UI for UWP DataGrid?
If I'm correct, please post in the UI for UWP - DataGrid forums. If I'm incorrect and this is for Xamarin.Forms, please send an updated code snippet and I'll be happy to assist further.
Normally, I could change the forum for you. However, since this thread originated by someone else under Telerik UI for Xamarin, you will need to re-post.
Note About Licensing and Post Location
I do not see any license for your account and you've never downloaded any Telerik product or held any Telerik license (with this account). If you are using the open source version instead of the commercial version of UI for UWP, please post this on StackOverflow (with a UI for UWP tag) or as a GitHub Issue (on the UI for UWP repo).
Although you can post in the UI for UWP forum, you would likely receive a faster answer on StackOverflow or GitHub as the forums and Support Ticket system are for the commercial version of Telerik UI for UWP.
I wish you the best of luck finding a happy solution.
Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik