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

[Solved] Grid server bind Initial, rebind with Ajax from client event?

1 Answer 140 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.
mike
Top achievements
Rank 1
mike asked on 31 Dec 2010, 08:14 PM
I have an insert form above a grid, what I'm trying to accomplish is this:
1. have the grid loaded on page load via server.
2. After the form submits its request to the server via an ajax call rebind the grid showing the updated data.

Is this possible? Could i just call this on view in a js method
$.ajax({
           url: '<%= Url.Action("GetDataColumns", "Ajax") %>',
           type: "POST",
           data: "dataSetId=" + _dataSetId,
           success: function (dcs) {
               var grid = $('#ColumnsGrid').data('tGrid');
               grid.dataBind(dcs);
           }
       });


then on controller call the following
[GridAction]
public ActionResult GetDataColumns(int dataSetId)
{
    List<ActionAlertLib.Classes.ActionAlert.DataColumn> _dcs = ActionAlertLib.Dal.ActionAlert.Load.GetDataColumns(dataSetId);
    return View(new GridModel(_dcs));
}


This seems to not rebind my grid. Thoughts?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
mike
Top achievements
Rank 1
answered on 31 Dec 2010, 08:23 PM
Figured it out. On the client side (view) needed to change the

grid.dataBind(dcs) --> grid.dataBind(dcs.data)

This worked.
Tags
Grid
Asked by
mike
Top achievements
Rank 1
Answers by
mike
Top achievements
Rank 1
Share this question
or