How Dynamical gridview for radButton in GridViewDataColumn

8 posts, 0 answers
  1. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    Hi All,
    We face an issue that we need to change current telerik grid to dynamical table(which is inherit from RadGridView,
     In previous implementation, There is radButton in  <telerik:GridViewDataColumn.CellTemplate>
    Here is the sample code:
    <telerik:GridViewDataColumn.CellTemplate>
          <DataTemplate>
         <telerik:RadButton Style="{StaticResource EditButtonStyle}" x:Name="EditButton" Margin="5,0,0,0"  Command="{Binding EditCustomCommand, Source={StaticResource ViewModel}}" CommandParameter="{Binding}"  / >
       </DataTemplate>
      </telerik:GridViewDataColumn.CellTemplate>

    But in dynamic table, How should we add this button,in current dynamic table only has databinding property,
    all column and row was created step by step for it.

    How should we create these buttons by xml:
    Here is my test code but no working:
      case "RadButton":
                            GridViewDataColumn radButton = new GridViewDataColumn();
                            StringBuilder cellBuilder = new StringBuilder();
                            cellBuilder.Append("<DataTemplate ");
                            cellBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/");
                            cellBuilder.Append("2006/xaml/presentation' ");
                     
                            cellBuilder.Append("xmlns:telerik='http://schemas.telerik.com/2008/xaml/presentation' ");
                            cellBuilder.Append("xmlns:local='clr-namespace:BindableDataGrid;assembly=BindableDataGrid'> ");
                            cellBuilder.Append(" <telerik:RadButton Style='{StaticResource EditButtonStyle}' x:Name='EditButton' Margin='5,0,0,0'    Command='{Binding EditCustomCommand, Source={StaticResource ViewModel}}'  CommandParameter='{Binding}'  ></telerik> ");
                            cellBuilder.Append("</DataTemplate>");
                            radButton.CellTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
       
                            radButton.CellEditTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
                            dgc = radButton;


    Any suggestion ?

           
     
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Sep 2012 Link to this post

    Hello,

     It will be better if you create custom column inherited from GridViewDataColumn (or GridViewColumn), override CreateCellElement and return desired UI element. 

    Greetings,
    Vlad
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    Hi, 
    Build Successfully and JIT was pass from these cs code  :

              GridViewDataColumn radButton = new GridViewDataColumn();
                            StringBuilder cellBuilder = new StringBuilder();
                            cellBuilder.Append("<DataTemplate ");
                            cellBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/");
                            cellBuilder.Append("2006/xaml/presentation' ");
                            cellBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
                            cellBuilder.Append("xmlns:telerik='http://schemas.telerik.com/2008/xaml/presentation' ");
                            cellBuilder.Append("xmlns:local='clr-namespace:BindableDataGrid;assembly=BindableDataGrid'> ");
                            cellBuilder.Append(" <telerik:RadButton  Margin='5,0,0,0'  />");
                            cellBuilder.Append("</DataTemplate>");
                            radButton.CellTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
                     
                            radButton.CellEditTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
                            dgc = radButton; 

    We notice that the column was added to dynamictable, but the page was in blank and no response anymore.It seems it doesn't work.if we 
    inherited from GridViewDataColumn (or GridViewColumn)  and create the radbutton, do you have any demo or sample code for reference, thank you in advance.

  4. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    GridViewDataColumn radButton = new GridViewDataColumn();
                           StringBuilder cellBuilder = new StringBuilder();
                           cellBuilder.Append("<DataTemplate ");
                           cellBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/");
                           cellBuilder.Append("2006/xaml/presentation' ");
                           cellBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
                           cellBuilder.Append("xmlns:telerik='http://schemas.telerik.com/2008/xaml/presentation' ");
                           cellBuilder.Append("xmlns:local='clr-namespace:BindableDataGrid;assembly=BindableDataGrid'> ");
                           cellBuilder.Append(" <telerik:RadButton  Margin='5,0,0,0'  />");
                           cellBuilder.Append("</DataTemplate>");
                           radButton.CellTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
                     
                           radButton.CellEditTemplate = (DataTemplate)XamlReader.Load(cellBuilder.ToString());
                           dgc = radButton;
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Sep 2012 Link to this post

    Hi,

     You can check these demos for more info about custom columns:
    http://demos.telerik.com/silverlight/#GridView/RowNumber
    http://demos.telerik.com/silverlight/#GridView/CustomColumn

    Greetings,
    Vlad
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    Dear Vlad,
    I have a question about CreateCellElement method, this is create a single control in a cell,How about mutiple control in a cell.  In current implementation, there r 2 radbuttons in a stackpanel by xaml
    <telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
    <StackPanel Style="{StaticResource CenterControlsCombinationStackPanelStyle}">
    <telerik:RadButton Style="{StaticResource EditButtonStyle}" x:Name="EditButton" Margin="5,0,0,0"  Command="{Binding EditCustomCommand, Source={StaticResource ViewModel}}" CommandParameter="{Binding}" />                                       
    <telerik:RadButton Style="{StaticResource SimpleRemoveButtonStyle}" x:Name="RemoveButton"    Command="{Binding RemoveCustomCommand, Source={StaticResource ViewModel}}" CommandParameter="{Binding}" Margin="5,0,5,0" />
          </StackPanel> 
    </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>

    For UI, pls refer 2 shot1.jpg. 

    If we inherit GridViewDataColumn  class and override CreateCellElement  , Does it support return a stackpanel with two radbuttons in it by override  CreateCellElement   method. If true,  How do you do? if not, do you have any suggestions? Thank you in advance.
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 27 Sep 2012 Link to this post

    Hi,

     Yes. You can create and return as many controls as you need. 

    Greetings,
    Vlad
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  8. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 27 Sep 2012 Link to this post

    Dear vlad,
    We've resolve this scenario, return StackPanel and add childElements to it, and then return it.
    Thank you for your quick response.
Back to Top