how to send GridSelectionMode.Multiple to the server

2 posts, 0 answers
  1. Maurice
    Maurice avatar
    14 posts
    Member since:
    Jan 2016

    Posted 02 Sep Link to this post

    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

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1801 posts

    Posted 06 Sep Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top