ActionColumn

Sep 5, 2012 at 10:49 AM

I've tried to add a ActionColumn to my grid:

.AddActionsColumn("actions", width: 25,                           
inlineEditingOptions: new JqGridInlineNavigatorActionOptions { Keys = true },                            editButton: false,                           
deleteOptions: new JqGridNavigatorDeleteActionOptions
{ Url = Url.Action("Slett", "Aktivitet") })

It works as planned, but something strange happens. The content of the cells is shifted one cell left. And when I look in the Chrome developer tools I see:

<td role="gridcell" style="display:none;" title="Befaring" aria-describedby="aktiviteterGrid_Id">Befaring</td>

The columnheadings are correct, but the last column get "undefined" as content.

I tried to remove all attributes from the viewmodel with the same result. And I tried to copy the html code from the InnlineEdit example...

Any suggestions?

Thomas

Coordinator
Sep 5, 2012 at 11:55 AM

Hi tnesser,

The issue here is that jqGrid is internally treating action column as any other standard column - it is trying to fill it with data (the helper can't fix this as this is jqGrid behaviour). There are two ways out of this:

  1. Add a dummy empty column to the result you are returning.
  2. Set JsonReader.RepeatItems property to false - this will cause jqGrid to look for values by name not index so the missing column will be skipped.

The sample project is using the second approach. If you look into Global.asax.cs you will see that this option is being set globaly on the JqGridRequest class so it affects all helper instances in the application:

protected void Application_Start()
{
    ...
    JqGridResponse.JsonReader.RepeatItems = false;
    ...
}

Sep 5, 2012 at 12:03 PM

I see, thank you for your answer :)

regards
Thomas

Aug 14, 2013 at 8:21 PM
Great, Thank you Guys :)