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

[Solved] Telerik MVC grid edit popup not closing - 2011.2.712.340

6 Answers 172 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.
Subhendu
Top achievements
Rank 1
Subhendu asked on 19 Sep 2011, 05:44 AM
Hi,

I have a fairly simple grid (version 2011.2.712.340) with ajax binding. The grid has editing set to popup. Everything was working fine till today. The "Add New Record" popup or the "Edit" popup, once opened, does not close with the "Insert" or "Update" button. The data does get saved as required. It is just that the popup remains open and does not close.

Here is the Model:
    public class DispatcherRequestDetails_Receiving
    {
        [Key]
        [DisplayName("Id")]
        public int DispatcherRequestDetails_Receiving_ID { get; set; }
        [UIHint("DispatcherRequestDropDownList")]
        public DispatcherRequest DispatcherRequest { get; set; }
        public int Request_No { get; set; }
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string RequestType { get; set; }
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string RequestStatus { get; set; }
        [UIHint("PartyMasterDropDownList")]
        public PartyMaster Party { get; set; }
        [UIHint("AddressBookDropDownList")]
        public AddressBook Location { get; set; }
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string Bin_No { get; set; }
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string Order_No { get; set; }
        public DateTime? Time { get; set; }
        [HiddenInput(DisplayValue = false)]
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string Unique_ID { get; set; }
        [HiddenInput(DisplayValue = false)]
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string Created_By { get; set; }
        [HiddenInput(DisplayValue = false)]
        public DateTime? Create_Date { get; set; }
        [HiddenInput(DisplayValue = false)]
        [StringLength(45, ErrorMessage = "Maximum length is 45")]
        public string Updated_By { get; set; }
        [HiddenInput(DisplayValue = false)]
        public DateTime? Last_Update_Date { get; set; }
    }

Here is the controller:
        [HttpPost]
        [GridAction(EnableCustomBinding = true)]
        public override ActionResult _Insert(DispatcherRequestDetails_Receiving data, GridCommand command)
        {
            if (Session["DispatcherRequestDetails_Receiving_Collection"] == null)
                Session["DispatcherRequestDetails_Receiving_Collection"] = new List<DispatcherRequestDetails_Receiving>();
            List<DispatcherRequestDetails_Receiving> lstDispatcherRequestDetails_Receiving = (List<DispatcherRequestDetails_Receiving>)Session["DispatcherRequestDetails_Receiving_Collection"];
            lstDispatcherRequestDetails_Receiving.Add(data);
            return Display(command);
        }
        protected override ActionResult Display(Telerik.Web.Mvc.GridCommand command)
        {
            if (Session["DispatcherRequestDetails_Receiving_Collection"] == null)
                Session["DispatcherRequestDetails_Receiving_Collection"] = new List<DispatcherRequestDetails_Receiving>();
            List<DispatcherRequestDetails_Receiving> lstDispatcherRequestDetails_Receiving = (List<DispatcherRequestDetails_Receiving>)Session["DispatcherRequestDetails_Receiving_Collection"];
           
            int totalRows = lstDispatcherRequestDetails_Receiving.Count;
            IEnumerable<DispatcherRequestDetails_Receiving> resultList = lstDispatcherRequestDetails_Receiving;
            return View(new GridModel { Data = resultList, Total = totalRows });
        }

Here is the Editor Template:
@model DispatcherRequestDetails_Receiving<br>
<div class="editor"><br>
    <br /><br>
    @Html.LabelFor(o => o.DispatcherRequestDetails_Receiving_ID)<br>
    @Html.EditorFor(o => o.DispatcherRequestDetails_Receiving_ID)<br>
    <br /><br>
    @Html.LabelFor(o => o.DispatcherRequest)<br>
    @Html.EditorFor(o => o.DispatcherRequest)<br>
    <br /><br>
    @Html.LabelFor(o => o.Request_No)<br>
    @Html.EditorFor(o => o.Request_No)<br>
    <br /><br>
    @Html.LabelFor(o => o.RequestType)<br>
    @Html.EditorFor(o => o.RequestType)<br>
    <br /><br>
    @Html.LabelFor(o => o.RequestStatus)<br>
    @Html.EditorFor(o => o.RequestStatus)<br>
    <br /><br>
    @Html.LabelFor(o => o.Party)<br>
    @Html.EditorFor(o => o.Party)<br>
    <br /><br>
    @Html.LabelFor(o => o.Location)<br>
    @Html.EditorFor(o => o.Location)<br>
    <br /><br>
    @Html.LabelFor(o => o.Bin_No)<br>
    @Html.EditorFor(o => o.Bin_No)<br>
    <br /><br>
    @Html.LabelFor(o => o.Order_No)<br>
    @Html.EditorFor(o => o.Order_No)<br>
    <br /><br>
    @Html.LabelFor(o => o.Time)<br>
    @Html.EditorFor(o => o.Time)<br>
    <br /><br>
</div><br>

Here is the View to display the grid:
<div class="grid">
<div class="grid">
    @(
        Html.Telerik().Grid<DispatcherRequestDetails_Receiving>()
        .BuildGrid(
            "DispatcherRequestGrid",
            "DispatcherRequestDetails_Receiving",
            Model.DispatcherRequest_ID.ToString()
        )
    )

And here is the helper method being used to create the grid:
public static GridBuilder<T> BuildGrid<T>(
    this GridBuilder<T> gridbuilder,
    string gridName,
    string ajaxController,
    object indexID) where T : class
{
    GridBuilder<T> retVal = gridbuilder.Name(gridName)
                        .EnableCustomBinding(true)
                        .ToolBar(commands => commands.Insert())
                        .Editable(editing => editing.Mode(Telerik.Web.Mvc.UI.GridEditMode.PopUp).Window(w => w.Modal(true)))
                        .Pageable(paging => paging.PageSize(20)
                            .Style(Telerik.Web.Mvc.UI.GridPagerStyles.NextPreviousAndNumeric)
                            .Total(100))
                        .DataBinding(bindings => bindings.Ajax()
                            .Select("_Index", ajaxController, new { id = indexID })
                            .Insert("_Insert", ajaxController)
                            .Update("_Update", ajaxController)
                            .Delete("_Delete", ajaxController));
 
    Type typeT = typeof(T);
    PropertyInfo[] properties = typeT.GetProperties();
 
    // Add keys
    GridDataKeyFactory<T> dataKeys = new GridDataKeyFactory<T>(retVal);
    foreach(PropertyInfo property in properties)
        if(IsAttributePresent<KeyAttribute>(property))
            dataKeys.Add(property.Name);
 
    // Add Columns
    GridColumnFactory<T> columns = new GridColumnFactory<T>(retVal);
    foreach (PropertyInfo property in properties)
        if(!IsAttributePresent<HiddenInputAttribute>(property))
            columns.Bound(property.Name);
    columns.Command(commands =>
        {
            commands.Edit().ButtonType(Telerik.Web.Mvc.UI.GridButtonType.Text);
            commands.Delete().ButtonType(Telerik.Web.Mvc.UI.GridButtonType.Text);
        }
    );
 
    return retVal;
}


I have seen a thread similar to my issue: http://www.telerik.com/community/forums/aspnet-mvc/grid/update-button-on-not-closing-popup.aspx

But it talks about updating to a version which is older than one that I use.

Any help is appreciated.

Thanks.
Subhendu.

6 Answers, 1 is accepted

Sort by
0
Quinten
Top achievements
Rank 1
answered on 30 Sep 2011, 10:49 PM
I'll just add a "me too" here.  Same version of the assembly (2011.2.712.340).  I've tried several different combinations of controller and view settings, as the examples on the Telerik site seem to vary quite a bit.  I guess I'll have to use server binding for now.
0
Quinten
Top achievements
Rank 1
answered on 30 Sep 2011, 11:48 PM
I tried upgrading to the newest release (2011.2.914.340), but the behavior is the same.
0
Rosen
Telerik team
answered on 03 Oct 2011, 07:58 AM
Hi Patrick Wirtz,

Usually such behavior may be experience if here are modelState validation errors. Therefore, could you please verify that  there are not errors. If you continue to experiencing difficulties please send us a small runnable project in which this can be recreated locally.

Greetings,
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
Arjun Paudel
Top achievements
Rank 1
answered on 08 Nov 2011, 10:48 AM
Same problem here with 2011.2.914 though Action is called on controller and data gets saved.
0
Rosen
Telerik team
answered on 08 Nov 2011, 11:14 AM
Hello Arjun Paudel,

Could you please provide a small sample which demonstrates the behavior in question. This way we will be able to provide more to-the-point answer.

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
Stephen
Top achievements
Rank 1
answered on 18 Nov 2011, 12:29 AM
I ran into this today too.

As rosen suggested, the problem turned out to be that the model state had errors.

More specifically, the errors in the modelstate in my case belonged to properties that did NOT have any corresponding UI elements on the page. There was no place for the validation messages to be displayed though.

My solution was:

  • check for model errors, and only save if there are no problems; I should have been doing that to start with
  • handle the onError client event so I can display any modelstate error messages that don't correspond directly to a UI field   
Tags
Grid
Asked by
Subhendu
Top achievements
Rank 1
Answers by
Quinten
Top achievements
Rank 1
Rosen
Telerik team
Arjun Paudel
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Share this question
or