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

Grid inside jqueryui dialog insert record issue

6 Answers 59 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.
Aleksander
Top achievements
Rank 1
Aleksander asked on 15 Mar 2012, 09:28 PM
I have the following grid inside a jqueryui dialog and I can insert the first record just fine but when i insert the 2nd one, when i return the view after adding the 2nd item I get a 500 error and i'm not sure what it's not finding since it found it the first time.

Grid Code:
<% Html.Telerik().Grid<SmartQuality.Presentation.Areas.Admin.Models.QuestionProperty>()
           .Name("gProperties")
           .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
           .DataKeys(keys => keys.Add(o => o.QuestionPropertyId))
           .Columns(columns =>
            {
                columns.Bound(o => o.Text);
                columns.Bound(o => o.Value);
                columns.Bound(o => o.OrderBy);
                columns.Bound(o => o.IsDefault);
                columns.Command(commands =>
                {
                    commands.Edit().ButtonType(GridButtonType.BareImage);
                    commands.Delete().ButtonType(GridButtonType.BareImage);
                }).Width(80);
            })
            .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                .Select("SelectPropertyToGrid", "Form")
                .Insert("InsertPropertyToGrid", "Form")
                .Update("UpdatePropertyToGrid", "Form")
                .Delete("DeletePropertyToGrid", "Form");
            })
            .Pageable()
            .Sortable()
            .Render();
    %>

Controller dataBinding functions:
[HttpPost]
        [GridAction]
        public ActionResult SelectPropertyToGrid()
        {
            return View(new GridModel(QuestionProperties));
        }
 
        [HttpPost]
        [GridAction]
        public ActionResult InsertPropertyToGrid()
        {
            QuestionProperty qp = new QuestionProperty();
 
            if (TryUpdateModel(qp))
            {
                QuestionProperties qps = this.QuestionProperties;
                qps.Add(qp);
                this.QuestionProperties = qps;
            }
 
            return View(new GridModel(QuestionProperties));
        }
 
        [HttpPost]
        [GridAction]
        public ActionResult UpdatePropertyToGrid(int id, string text, decimal value, int orderBy, bool isDefault)
        {
            QuestionProperty qp = this.QuestionProperties.Find(o => o.QuestionPropertyId == id);
 
            QuestionProperties qps = this.QuestionProperties;
 
            qp.Text = text;
            qp.Value = value;
            qp.OrderBy = orderBy;
            qp.IsDefault = isDefault;
 
            TryUpdateModel(qp);
 
            this.QuestionProperties = qps;
 
            return View(new GridModel(QuestionProperties));
        }
 
        [HttpPost]
        [GridAction]
        public ActionResult DeletePropertyToGrid(int id)
        {
            QuestionProperty qp = this.QuestionProperties.Find(o => o.QuestionPropertyId == id);
 
            if (qp != null)
            {
                QuestionProperties qps = this.QuestionProperties;
                qps.Remove(qp);
                this.QuestionProperties = qps;
            }
 
            return View(new GridModel(QuestionProperties));
        }

am i missing something?

6 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Mar 2012, 12:56 PM
Hi Aleksander,

It seems that there is an exception being thrown while you are trying to update the item.
You can try to run the project in debug to let the visual studio popup when the error occurs, or you can use Developer tools for Chrome and IE or Firebug for Firefox to check what exactly is the result (I suppose it is yellow screen).
If this does not help you please send us a runnable project which reproduces the problem so we can check for a solution.

All the best,
Petur Subev
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
Aleksander
Top achievements
Rank 1
answered on 20 Mar 2012, 03:35 PM
what do you mean by "(I suppose it is yellow screen)."

0
Petur Subev
Telerik team
answered on 20 Mar 2012, 05:18 PM
Hi again Aleksander,

By yellow screen I mean the error page which is returned by the application when an error occurs (which is visible in debug compilation mode by default). It typically gives information to easy locate the error.

All the best,
Petur Subev
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
Aleksander
Top achievements
Rank 1
answered on 22 Mar 2012, 07:48 PM
I get a 500 error stating that it's not an IComparable? Any thoughts? We're using a grid exactly like this in another project and it works fine w/o the IComparable.
0
Aleksander
Top achievements
Rank 1
answered on 22 Mar 2012, 08:14 PM
It also shows that the first record is inserted and it posts with JSON. the 2nd time i insert a record is shows HTML not JSON when using firefox.
0
Aleksander
Top achievements
Rank 1
answered on 22 Mar 2012, 09:06 PM
Fixed... On my object I had to extend IComparable and just create a CompareTo function and it fixed the issue.
Tags
Grid
Asked by
Aleksander
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Aleksander
Top achievements
Rank 1
Share this question
or