This project is read-only.

Render multiple hyperlinks (with appropriate ID for Model record) in Grid?

Jan 29, 2015 at 5:28 PM
Edited Jan 29, 2015 at 5:30 PM
I have got the following correctly working:
<div class="assetList">

    @*Images in Columns: https://gridmvc.codeplex.com/discussions/440977*@
    @try
    {
        @Html.Grid(Model).Columns(columns =>
        {
            
            columns.Add().Encoded(false).Sanitized(false).RenderValueAs(o => @<a href="/INV_Locations/Edit/@o.Id" class="btn btn-success btn-sm noDecoration"><span class="glyphicon glyphicon-pencil"></span> Edit</a>).SetWidth(15);
            columns.Add().Encoded(false).Sanitized(false).RenderValueAs(o => @<a href="/INV_Locations/Details/@o.Id" class="btn btn-default btn-sm noDecoration"><span class="glyphicon glyphicon-eye-open"></span> View</a>).SetWidth(15);
            columns.Add().Encoded(false).Sanitized(false).RenderValueAs(o => @<a href="/INV_Locations/Delete/@o.Id" class="btn btn-danger btn-sm noDecoration"><span class="glyphicon glyphicon-remove-circle"></span> Delete</a>).SetWidth(15);


            columns.Add(o => @<a href="/INV_Locations/Edit/@o.Id" class="btn btn-success btn-sm noDecoration"><span class="glyphicon glyphicon-pencil"></span> Edit</a> o => @<a href="/INV_Locations/Details/@o.Id" class="btn btn-default btn-sm noDecoration"><span class="glyphicon glyphicon-eye-open"></span> View</a>);
            columns.Add(o => o.location_dept).Titled("Dept").RenderValueAs(o => o.location_dept).Sanitized(false).Encoded(false).Sortable(true).Filterable(true).SetWidth(20);
            columns.Add(o => o.location_room).Titled("Room").RenderValueAs(o => o.location_room).Sanitized(false).Encoded(false).Sortable(true).Filterable(true).SetWidth(20);
            columns.Add(o => o.created_date).Titled("Crtd. Date").RenderValueAs(o => Convert.ToString(o.created_date)).SetWidth(20);
            columns.Add(o => o.created_by).Titled("By").RenderValueAs(o => o.created_by).SetWidth(20);
            columns.Add(o => o.modified_date).Titled("Mod. Date").RenderValueAs(o => Convert.ToString(o.modified_date)).SetWidth(20);
            columns.Add(o => o.modified_by).Titled("By").RenderValueAs(o => o.modified_by).SetWidth(20);
        }).WithPaging(10).Sortable().Filterable().WithMultipleFilters();
    }
    catch (NullReferenceException ex)
    {
        return;
    }
</div>
While my buttons for [EDIT]|[VIEW]|[DELETE]| function, I would ideally like them all displaying inline in the SAME column.

Does anyone know the syntax to get this done?

I found [THIS about putting multiple buttons in the same column, but I need to also include the relevant record instance [ID] value so that my App knows which record to Edit/View/Delete.

Can anyone assist with this?

Following the above link, I created a helper method but am stuck on getting the correct ID. This is what I have currently for the helper():
@helper CustomRenderingOfColumn() {
    <a href="/INV_Locations/Edit/@o.Id" class="btn btn-success btn-sm noDecoration"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
    <a href="/INV_Locations/Details/@o.Id" class="btn btn-default btn-sm noDecoration"><span class="glyphicon glyphicon-eye-open"></span> View</a>
    <a href="/INV_Locations/Delete/@o.Id" class="btn btn-danger btn-sm noDecoration"><span class="glyphicon glyphicon-remove-circle"></span> Delete</a>
}
The [@o] of course currently flags as "not existing in the current context".