What’s New in Telerik UI for Xamarin DataGrid Control?

栏目: IT技术 · 发布时间: 5年前

内容简介:With R2 2020 release ofWe love to listen to your feedbackand the filtering capabilities of theIn this blog post I will get you familiar with the new DataGrid Columns features

With R2 2020 release of Telerik UI for Xamarin we have implemented three powerful new features for the RadDataGrid that allow you to customize the content template and edit template of cells. These options are available for all columns provided by the DataGrid control.

We love to listen to your feedbackand the filtering capabilities of the DataGrid TemplateColumn  was one of the most requested features by you, so we pulled it off just in time for our new major release! The feature is now part of the DataGrid features set.

In this blog post I will get you familiar with the new DataGrid Columns features CellContentTemplate , CellEditTemplate and the new filtering option— FilterControlTemplate .

Customize the ContentTemplate of Cells

This feature enables users to customize the look of the content of the cell using their own DataTemplate and at the same time the RadDataGrid will be able to execute operations like grouping, sorting and filtering over that column. This is possible since the meta information that comes with the type of the column is still available for the grid component.

What’s New in Telerik UI for Xamarin DataGrid Control?

Below is the source code used for the above GIF.

Sample business model definition:

public class City

{

    public string Name { get; set; }

    public int Population { get; set; }

    public DateTime? Visited { get; set; }

    public bool IsVisited { get; set; }

}

The ViewModel:

public class ViewModel

{

   public ViewModel()

   {

     this .Items = new ObservableCollection<City>

     {

       new City{Name = "London" , Visited = new DateTime(2019,03,15), IsVisited = true , Population = 8982000},

       new City{Name = "New York" , Visited = null , IsVisited = false , Population = 8399000},

       new City{Name = "Tokyo" , Visited = new DateTime(2019,11,12), IsVisited = true , Population = 9273000},

       new City{Name = "Madrid" , Visited = null , IsVisited = false , Population = 6642000},

       new City{Name = "Paris" , Visited = null , IsVisited = false , Population = 2148000},

       new City{Name = "Berlin" , Visited = new DateTime(2017,12,27), IsVisited = true , Population = 3769000},

     };

   }

   public ObservableCollection<City> Items { get ; set ; }

}

Next, we have the DataGrid XAML Definition with CellContentTemplate property set to TextColumn , BooleanColumn and DateColumn . The CellContentTemplate of the DateColum uses RadDatePicker for Xamarin control. 

< telerikDataGrid:RadDataGrid x:Name = "dataGrid"

               ItemsSource = "{Binding Items}"

               AutoGenerateColumns = "False"

               UserEditMode = "Cell" >

   < telerikDataGrid:RadDataGrid.BindingContext >

     < local:ViewModel />

   </ telerikDataGrid:RadDataGrid.BindingContext >

   < telerikDataGrid:RadDataGrid.Columns >

     < telerikDataGrid:DataGridTextColumn PropertyName = "Name"

                       Width = "100"

                       SizeMode = "Fixed"

                       HeaderText = "City" >

       < telerikDataGrid:DataGridColumn.CellContentTemplate >

         < DataTemplate >

           < Label Text = "{Binding Name}"

               VerticalOptions = "Center" />

         </ DataTemplate >

       </ telerikDataGrid:DataGridColumn.CellContentTemplate >

     </ telerikDataGrid:DataGridTextColumn >

     < telerikDataGrid:DataGridBooleanColumn PropertyName = "IsVisited"

                         HeaderText = "Visited?" >

       < telerikDataGrid:DataGridColumn.CellContentTemplate >

         < DataTemplate >

           < StackLayout Orientation = "Horizontal" >

             < Label Text = "{Binding Source={x:Reference switch}, Path=IsToggled}"

                 VerticalOptions = "Center" />

             < Switch IsToggled = "{Binding IsVisited}"

                 x:Name = "switch"

                 VerticalOptions = "Center" />

           </ StackLayout >

         </ DataTemplate >

       </ telerikDataGrid:DataGridColumn.CellContentTemplate >

     </ telerikDataGrid:DataGridBooleanColumn >

     < telerikDataGrid:DataGridDateColumn PropertyName = "Visited"

                       HeaderText = "Date Visited" >

       < telerikDataGrid:DataGridColumn.CellContentTemplate >

         < DataTemplate >

           < telerikInput:RadDatePicker Date = "{Binding Visited}"

                         DisplayStringFormat = "yyyy/MMM/dd"

                         VerticalOptions = "Center" />

         </ DataTemplate >

       </ telerikDataGrid:DataGridColumn.CellContentTemplate >

     </ telerikDataGrid:DataGridDateColumn >

   </ telerikDataGrid:RadDataGrid.Columns >

</ telerikDataGrid:RadDataGrid >

Customize the EditTemplate of Cells

RadDataGrid now allows you to modify the template of a cell when it goes into edit mode. This can be easily done with the CellEditTemplate property which is shared between all existing column types.

What’s New in Telerik UI for Xamarin DataGrid Control?

Demo:Let's use the same Business Model and ViewModel as in the CellContentTemplate Example. Here is the DataGrid XAML definition used with CellEditTemplate property set:

< telerikDataGrid:RadDataGrid x:Name = "dataGrid"

               ItemsSource = "{Binding Items}"

               AutoGenerateColumns = "False"

               UserEditMode = "Cell" >

   < telerikDataGrid:RadDataGrid.BindingContext >

     < local:ViewModel />

   </ telerikDataGrid:RadDataGrid.BindingContext >

   < telerikDataGrid:RadDataGrid.Columns >

     < telerikDataGrid:DataGridTextColumn PropertyName = "Name"

                       HeaderText = "City" >

       < telerikDataGrid:DataGridColumn.CellEditTemplate >

         < DataTemplate >

           < StackLayout Orientation = "Horizontal" >

             < Entry Text = "{Binding Item.Name, Mode=TwoWay}"

                 Margin = "5"

                 ReturnCommand = "{Binding CommitEditCommand}" />

             < Button Text = "Cancel" Command = "{Binding CancelEditCommand}" />

           </ StackLayout >

         </ DataTemplate >

       </ telerikDataGrid:DataGridColumn.CellEditTemplate >

     </ telerikDataGrid:DataGridTextColumn >

     < telerikDataGrid:DataGridBooleanColumn PropertyName = "IsVisited"

                         HeaderText = "Visited?" >

       < telerikDataGrid:DataGridColumn.CellEditTemplate >

         < DataTemplate >

           < StackLayout Orientation = "Horizontal" >

             < Switch IsToggled = "{Binding Item.IsVisited, Mode=TwoWay}" />

             < Button Text = "Cancel" Command = "{Binding CancelEditCommand}" />

             < Button Text = "OK" Command = "{Binding CommitEditCommand}" />

           </ StackLayout >

         </ DataTemplate >

       </ telerikDataGrid:DataGridColumn.CellEditTemplate >

     </ telerikDataGrid:DataGridBooleanColumn >

    </ telerikDataGrid:RadDataGrid.Columns >

</ telerikDataGrid:RadDataGrid >

New Filtering Feature—FilterControlTemplate

The Xamarin DataGrid extends the functionality of the TemplateColumn of the component and will now support filtering. You can define a custom template for the filtering UI as well as custom filtering logic. And not only for TemplateColumn, The FilterControlTemplate property can be applied to all DataGrid columns.

What’s New in Telerik UI for Xamarin DataGrid Control?

The source code of the FilterControl Template Demo can be found in our SDK Browser application/Examples/DataGridControl/FilteringCategory section.

Tell Us What You Think

We would love to hear what you think about the new DataGrid features. If you have any ideas for new features to add, do not hesitate to share this information with us on our Telerik UI for Xamarin Feedback portal .

Don’t forget to check out the various demos of the control in our SDK Sample Browser and the Telerik UI for Xamarin  Demos  application.

Real-World Xamarin App Examples

several fully functional, real-world Xamarin.Forms application examples .

  • AndroidiOSUWP
  • AndroidiOSUWP
  • AndroidiOSUWP
  • AndroidiOSUWP

Examples source code can be checked in the Telerik Xamarin.Forms Samples GitHub repo .

Happy coding with our controls and stay with us! We would love to share more with you in an upcoming blog post about Date Picker , Time Picker , TimeSpan Picker and Telerik Mobile Blazor Bindings for Xamarin


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

jQuery实战

jQuery实战

Bear Bibeault、Yehuda Katz / 陈宁 / 人民邮电出版社 / 2009.1 / 49.00元

《jQuery实战》全面介绍jQuery知识,展示如何遍历HTML文档、处理事件、执行动画以及给网页添加Ajax。书中紧紧地围绕“用实际的示例来解释每一个新概念”这一宗旨,生动描述了jQuery如何与其他工具和框架交互以及如何生成jQuery插件。jQuery 是目前最受欢迎的JavaScript/Ajax库之一,能用最少的代码实现最多的功能。 点击链接进入新版: jQuery......一起来看看 《jQuery实战》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具