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

Html.ActionLink not working in a Kendo grid

3 Answers 306 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Pullella
Top achievements
Rank 1
Michael Pullella asked on 02 Jul 2012, 02:42 PM
@(  Html.Kendo().Grid(Model.Notifications)
        .Name("gridTitanNotifications")
        .Columns(columns => {
            columns.Template(
                @<text>                   
                    <input name="chkNotifications" type="checkbox" value="@item.InstanceID " title="checked notification"/>               
                </text>).Title("").Width(36);
 
            columns.Bound(m => m.NotificationText).Title("Notification");
 
            columns.Template(m => {
                switch (m.LinkType) {
                    case Titan.Entities.Enums.Notification.LinkTypes.Internal:
                        Html.ActionLink("TEST", "test");
                //                      Html.ActionLink(m.LinkText, m.LinkAction, m.LinkController, new { instanceID = m.LinkInstanceID });
                        break;
                    case Titan.Entities.Enums.Notification.LinkTypes.External:
                        break;
                }
            }).Title("Case");
 
            //          columns.Bound(m => m.LinkText).Title("Case");
            columns.Bound(m => m.TimestampCreated).Title("Recieved");
        })
 
                                .RowAction(row => {
                                    if (!row.DataItem.ReadFlag) {
                                        row.HtmlAttributes["style"] = "font-weight: bold";
                                    }
                                })
                        )

3 Answers, 1 is accepted

Sort by
0
Michael Pullella
Top achievements
Rank 1
answered on 02 Jul 2012, 02:48 PM
Sorry about this... Page posted accidentally.
I am trying to get a link ot appear in a Kendo grid via the code below

The link (generated via the column.template) will not display anything in the Case column.  If I do the columns.Bound(m=> m.LinkText).Title("Case"), however I do see the data displayed correctly.


I have tried something as basic as Html.ActionLink("TEST", "test"); but that doesn't display anything either.
I really need the line

 Html.ActionLink(m.LinkText, m.LinkAction, m.LinkController, new { instanceID = m.LinkInstanceID });

to work.  Any suggestions as to what I may be doing incorrectly? 

0
Michael Pullella
Top achievements
Rank 1
answered on 02 Jul 2012, 07:04 PM
Something to add to this:

I can get the link to appear if I do something like this:
columns.Template(m => Html.ActionLink(m.NotificationText, null));

but without the braces, I have no way of doing a switch statement, etc
0
Rosen
Telerik team
answered on 03 Jul 2012, 11:58 AM
Hi Michael,

You should output the ActionLink generated html instead of just calling the method, something similar to the following:

columns.Template(
    @<text>
        @{switch (item.LinkType)
            {
                case Titan.Entities.Enums.Notification.LinkTypes.Internal:
                    @Html.ActionLink("TEST", "test");                         
                    break;
                case Titan.Entities.Enums.Notification.LinkTypes.External:
                    break;
            }         
    } 
    </text>).Title("Case");

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Michael Pullella
Top achievements
Rank 1
Answers by
Michael Pullella
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or