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

how to send GridSelectionMode.Multiple to the server

1 Answer 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maurice
Top achievements
Rank 1
Veteran
Maurice asked on 02 Sep 2016, 08:56 AM

Hi,

I have a page with a grid with .Selectable(s => s.Type(GridSelectionType.Row).Mode(GridSelectionMode.Multiple)) and can select multiple lines. And I have a DropDownList.

What I want is to send an array of selected lines in the grid to the server AND the information of the dropdownlist.

If I want only one of this information I know how to do it but somewhere my ajax call gets corrupted.

If I have the following:

View:
var items= {};
            var grid = $('#grid').data('kendoGrid');
            var selectedElements = grid.select();
            for (var j = 0; j < selectedElements.length; j++) {
                var item = grid.dataItem(selectedElements[j]);
                items['projectMoveModels[' + j + '].ID'] = item.ID;
                items['projectMoveModels[' + j + '].DateString'] = item.Date;
                items['projectMoveModels[' + j + '].EmployeeID'] = item.EmployeeID;
                items['projectMoveModels[' + j + '].Hours'] = item.Hours;
            }
            $.ajax({
                type: "POST",
                data: items,
                url: '@Url.Action("Move", "Project")',
                }
            })

And in the controller

public ActionResult Move(IList<ProjectMoveModel> projectMoveModels)

I do receive all selected lines in projectMoveModels.

 

But I want more data so I changed it to

var type = 1; //info from the dropdownlist
            $.ajax({
                type: "POST",
                data: { projectMoveModels: items, type: type },

with in the controller

public ActionResult Move(IList<ProjectMoveModel> projectMoveModels, object type)

 

Now projectMoveModels will became null

 

How can I fix this error?

 

Thanks in advance

Maurice

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Sep 2016, 11:30 AM
Hello Maurice,

You could take a look at the following forum threads that should help you achieve the desired result:
Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Maurice
Top achievements
Rank 1
Veteran
Answers by
Konstantin Dikov
Telerik team
Share this question
or