How to use commands in datagrid?

12 posts, 0 answers
  1. JavascriptParrot
    JavascriptParrot avatar
    1 posts
    Member since:
    Dec 2016

    Posted 13 Feb 2018 Link to this post

    How can I execute a job if the cell is being tapped twice? I can not find examples...
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    665 posts

    Posted 15 Feb 2018 Link to this post

    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
  3. Stavros
    Stavros avatar
    18 posts
    Member since:
    Oct 2017

    Posted 26 Mar 2018 Link to this post

    Hi,

    Is there any example of validating a cell ?? 

    I can't find any either. 

  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    665 posts

    Posted 27 Mar 2018 Link to this post

    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
  5. Stavros
    Stavros avatar
    18 posts
    Member since:
    Oct 2017

    Posted 28 Mar 2018 in reply to Stefan Nenchev Link to this post

    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

     

  6. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    665 posts

    Posted 28 Mar 2018 Link to this post

    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
  7. Ryan
    Ryan avatar
    3 posts
    Member since:
    Apr 2016

    Posted 26 Apr 2018 Link to this post

    can you please Provide some examples of these Commands declared using XAML ?
  8. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    665 posts

    Posted 01 May 2018 Link to this post

    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
  9. AllCloud
    AllCloud avatar
    3 posts
    Member since:
    Sep 2018

    Posted 01 Oct 2018 Link to this post

    How to Navigate to another page when we tapped on the cell in the DataGrid in telerik xamarin using the commands?
  10. Didi
    Admin
    Didi avatar
    356 posts

    Posted 02 Oct 2018 Link to this post

    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
  11. Andrew
    Andrew avatar
    1 posts
    Member since:
    Jun 2019

    Posted 19 Jun 2019 Link to this post

    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

  12. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1168 posts

    Posted 19 Jun 2019 Link to this post

    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
Back to Top