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

[Solved] MVC Menu in a Cell of MVC Grid, Ajax bound?

4 Answers 113 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.
bbeatty
Top achievements
Rank 1
bbeatty asked on 14 Mar 2012, 11:00 PM
I'm trying to create a client template with a Menu control.
I'm binding my grid using Ajax and Razor.

Is this possible or should I switch to server and use Templates?

Thanks,
Brian

4 Answers, 1 is accepted

Sort by
0
Accepted
Dadv
Top achievements
Rank 1
answered on 15 Mar 2012, 12:42 PM
Hi,

I think this is possible if you use .ToHtmlString() like in this sample
0
bbeatty
Top achievements
Rank 1
answered on 15 Mar 2012, 09:21 PM
That worked well.
How would I have conditional items in the menu?

ex:
columns.Bound(m => m.Id).ClientTemplate(
                    Html.Telerik().Menu()
                        .Name("Menu1_<#=Id #>").HtmlAttributes(new { style = "z-order:100000000" })
                    .Orientation(MenuOrientation.Vertical)
                    .Items(menu => menu.Add().Text("Actions")
                                .Items(sub =>
                                {
                                    sub.Add().Text("Notify");
//If FieldX == ValueA then  sub.Add().Text("Continue ");
//if fieldZ == ValueB then   sub.Add().Text("Take ");
                                }))

                        .ToHtmlString()
                    );

0
Dadv
Top achievements
Rank 1
answered on 16 Mar 2012, 09:16 AM
I don't know if it is possible, this is probably the same behavior than here, and you should consider the context.

If the menu item is a security risk then you should bind it to a Model and extract the value from the server otherwise if it's a simple visual effect then you could do it in  jquery via the client side API (use OnRowDataBound of the grid for example).
0
Dadv
Top achievements
Rank 1
answered on 16 Mar 2012, 09:26 AM
Alternatively you could replace the Menu control by a ComboBox control, this will give you more flexibility for the binding (load on demand).
Tags
Grid
Asked by
bbeatty
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
bbeatty
Top achievements
Rank 1
Share this question
or