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

How to use commands in datagrid?

11 Answers 260 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
JavascriptParrot
Top achievements
Rank 1
JavascriptParrot asked on 13 Feb 2018, 10:12 AM
How can I execute a job if the cell is being tapped twice? I can not find examples...

11 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 15 Feb 2018, 11:26 AM
Hello, Gertjan,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stavros
Top achievements
Rank 1
answered on 26 Mar 2018, 10:24 AM

Hi,

Is there any example of validating a cell ?? 

I can't find any either. 

0
Stefan Nenchev
Telerik team
answered on 27 Mar 2018, 01:59 PM
Hi, Stavros,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stavros
Top achievements
Rank 1
answered on 28 Mar 2018, 08:42 AM

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

 

0
Stefan Nenchev
Telerik team
answered on 28 Mar 2018, 11:05 AM
Hi, 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 27 Apr 2018, 03:10 AM
can you please Provide some examples of these Commands declared using XAML ?
0
Stefan Nenchev
Telerik team
answered on 01 May 2018, 01:33 PM
Hello, Ryan,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
AllCloud
Top achievements
Rank 1
answered on 01 Oct 2018, 11:25 AM
How to Navigate to another page when we tapped on the cell in the DataGrid in telerik xamarin using the commands?
0
Didi
Telerik team
answered on 02 Oct 2018, 11:15 AM
Hi,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 19 Jun 2019, 02:28 PM

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

0
Lance | Manager Technical Support
Telerik team
answered on 19 Jun 2019, 04:58 PM
Hello Andrew,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
JavascriptParrot
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Stavros
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
AllCloud
Top achievements
Rank 1
Didi
Telerik team
Andrew
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or