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

[Solved] MVC Ajax Editing Buttons column disappears

3 Answers 91 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.
iConect Developer - Mike
Top achievements
Rank 1
iConect Developer - Mike asked on 18 Nov 2011, 01:59 AM
Ok so I have this grid inside a partial view and whenever you edit an item then click the confirm button, it does a quick refresh that removes the data's Command column (the header column is still there). Any idea what's causing this?

view:
@model AssessmentModels.FilterDateModel
<div class="view_panel">
  @{
    Html.Telerik().Grid<AssessmentModels.FilterDateModel.RowItem>(Model.Items)
      .Name("gridDate")
      .DataKeys(keys =>
      {
        keys.Add(c => c.Type);
      })
      .Columns(columns =>
      {     
        columns.Bound(o => o.Type);
        columns.Bound(o => o.StartDate)
          .HeaderHtmlAttributes(new { style = "text-align:center;" })
          .FooterHtmlAttributes(new { style = "text-align:center;" })
          .HtmlAttributes(new { style = "text-align:center;" })
          .Width(100);
        columns.Bound(o => o.EndDate)
          .HeaderHtmlAttributes(new { style = "text-align:center;" })
          .FooterHtmlAttributes(new { style = "text-align:center;" })
          .HtmlAttributes(new { style = "text-align:center;" })
          .Width(100);
 
        columns.Bound(o => o.Group)
          .GroupHeaderTemplate(@<text>@item.Key</text>)
          .Hidden();
 
        columns.Command(commands =>
        {
          commands.Edit().ButtonType(GridButtonType.Image);
        })
          .Title("Edit")
          .HeaderHtmlAttributes(new { style = "text-align:center;" })
          .FooterHtmlAttributes(new { style = "text-align:center;" })
          .Width(60);
      })
      .DataBinding(dataBinding =>
      {
        dataBinding.Ajax()
          .Select("FilterDateGrid_Select", "Assessment")
          //.Insert("FilterDateGrid_Insert", "Assessment")
          .Update("FilterDateGrid_Save", "Assessment")
          .Delete("FilterDateGrid_Delete", "Assessment");
      })
      .Scrollable(scrolling => scrolling.Height(450).Enabled(true))
      .Sortable(sorting => sorting.Enabled(false))
      .Editable(editing => editing.Mode(GridEditMode.InLine))
      .Pageable(paging => paging.Enabled(false))
      .Footer(false)
      .Render();
  }
</div>

Controller:
#region Date Grid
public ActionResult FilterDateGrid_Edit()
{
  return View();
}
 
[GridAction]
public ActionResult FilterDateGrid_Select()
{
  return View(new GridModel(_vm.FilterDate.Items));
}
 
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult FilterDateGrid_Save(string id)
{
  AssessmentModels.FilterDateModel.RowItem item = _vm.FilterDate.OneItem(i => i.Type == id);
 
  TryUpdateModel(item);
  _vm.FilterDate.UpdateItem(item);
  return View(new GridModel(_vm.FilterDate.Items));
}
#endregion Date Grid

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 18 Nov 2011, 11:55 AM
Hello,

I'm afraid that I'm not sure what may be the exact cause for the behavior you have described judging from the provided information. Thus, it will be appreciated if you could send us a small sample in which this can be observed. Meanwhile, could you verify that all the resources (such as scripts and css) are loaded correctly after the actions you have described and there are no JavaScript errors. 

Regards,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
iConect Developer - Mike
Top achievements
Rank 1
answered on 28 Nov 2011, 07:07 PM
Here you go, the basic project with a grid having the issues.
0
Accepted
Rosen
Telerik team
answered on 29 Nov 2011, 08:37 AM
Hi Keith,

Thank you for the sample. As you may know when using hidden columns they should be placed as last columns - after all visible columns. Therefore, moving the hidden column after the command column should resolve the described issue.

All the best,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
iConect Developer - Mike
Top achievements
Rank 1
Answers by
Rosen
Telerik team
iConect Developer - Mike
Top achievements
Rank 1
Share this question
or