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

[Solved] Convert Client Template String to Column Template

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nicole
Top achievements
Rank 1
Nicole asked on 03 Nov 2011, 04:13 PM

Hi, I have been working on putting a wrapper around the grid, so that based on certain values that are set, the grid can then be generated server side and returned. Below is an example of the model used to set the values and the function used to generate the grid. I was wondering if there was a way to use the string of a client template to set a column template value?

Example:

public class GridModelExample

{

                private List<ColumnDefinition> _Columns =  new List<ColumnDefinition>();

                public List<ColumnDefinition> Columns

                {

                                get {  return _Columns; }

                                set { _Columns = value; }

                }

                public GridModel GetData()

                {

                                …   

                }

                .

                .

                .

}

public class ColumnDefinition

{

                private string _Name = “name of column”;

                public string Name

                {

                                get {  return _Name; }

                                set {  _Name = value; }

                }

                private string _ClientTemplate = “string value for client template”;

                public string ClientTemplate

                {

                                get {  return _ ClientTemplate; }

                                set {  _ ClientTemplate = value; }

                }

}

public functionToGenerateGrid(GridModeExample)

{

                    _GridBuilder = Telerik.Web.Mvc.UI.HtmlHelperExtension.Telerik(helper).Grid<T>()

                                    .Name(Grid.Name)

                                    .EnableCustomBinding(true)

                                    .BindTo(Grid.GetData());

 

                    foreach (ColumnDefinition column in GridModelExample.Columns)

                    {

                                        _GridBuilder = _GridBuilder.Columns(col =>
                                        {                   
                                                            GridBoundColumnBuilder<T> columnBoundBuilder = col
                                                                                                      .Bound(column.Name)
                                                                                                     .ClientTemplate(column.ClientTemplate);
                                                             //want to add:
                                                             // columnBoundBuilder = columnBoundBuilder
                                                             //                                    .Template(set from client template);
                                        });
                    }
}

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 07 Nov 2011, 10:03 AM
Hi Nicole,

I'm afraid that this is not possible. There is not direct match between string declaration of client template and delegate required by the server template.

Regards,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Nicole
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or