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

[Solved] Dynamic MVC3 Grid - Header Colors-Remove Buttons

0 Answers 47 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.
Neil Watts
Top achievements
Rank 1
Neil Watts asked on 24 Jul 2012, 05:44 PM
Hello,

I have an MVC3 razor View with a dynamic telerik grid. I bind the grid to a ViewModel that has a Datatable and IEnumerable gridcolumnsettings.

I have a few related questions.

1. I need to know how to hide buttons on certain rows. With the dynamic nature I dont know how to access the particular rows items.

2. How would I change the colors of some of the actual Header Columns?

3. With the dynamic nature of the data, how would I add additional data to the Header. Ex. I need to show some numerical values in the headers on a dynamic number of the column headers.

Ex. if I am showing parts, I need to show the part name, below that the total ordered and below that the total that havent been shipped out.

Here is my grid code
                                    @(Html.Telerik().Grid<System.Data.DataRow>(Model.Data.Rows.Cast<System.Data.DataRow>())
                                            .HtmlAttributes(new { style = "width: 2500px" })
                                            .Name("Grid")
                                            .ToolBar(tb => tb.Template("Outstanding Orders"))
                                            .DataKeys(dataKeys => dataKeys.Add("DeliveryID"))
                                            .Columns(columns =>
                                            {
                                                columns.Command(commandbutton =>
                                                {
                                                    commandbutton.Select().ButtonType(GridButtonType.ImageAndText).HtmlAttributes(new { style = "width: 60px; min-width: 40px; background: #0066FF" });
                                                }).Width(120).Title(ViewBag.Mark);
                                                
                                                columns.LoadSettings(Model.Columns as IEnumerable<GridColumnSettings>);
                                            })
                                            .RowAction(row =>
                                            {
                                                if (row.Index < 2)
                                                {
                                                    row.HtmlAttributes["style"] = "background:#336699;";
                                                }
                                            })
                                            .DataBinding(dataBinding => dataBinding.Server()
                                                    .Select("_DeliveryGrid", "Deliveries")
                                                    .Update("_DeliveryGrid", "Deliveries"))
                                            .Editable(editing => editing.Mode(GridEditMode.InLine))
                                            .Sortable(settings => settings.Enabled(true))
                                            .Scrollable(c => c.Height("9000px"))
                                            .EnableCustomBinding(true)
                                            .Resizable(resize => resize.Columns(true))
                                     )

Any help would be greatly appreciated.
Tags
Grid
Asked by
Neil Watts
Top achievements
Rank 1
Share this question
or