locked
how to send selected row values from a jqgrid to controller on button click RRS feed

  • Question

  • User569149469 posted
                jQuery("#jqgrid").jqGrid({
                    datatype: 'Json',
                     mtype: 'GET',
                     url: '@Url.Action("SearchGridData", "GenericData")',
                    width: "auto",
                  height: '490',
                 
                    rowNum: 999999,
                    scroll: true,
                    colNames: ['Id', ' Name', 'Test', 'Location'],
                    colModel: [
                        {
                            name: 'Id',
                            index: 'Id',
                            width: 60,
                            sorttype: "int"
                        },
                       
                        {
                            name: 'Name',
                            index: 'Name',
                            width: 100
                        },
                        {
                            name: 'Test',
                            index: 'Test',
                            width: 100
                          
                        },
                        {
                            name: 'Location',
                            index: 'Location',
                            width: 100
                        }
                    ],
                    
                    pager: "#pager",
                    viewrecords: true,
                    multiselect: true,
                    caption: "Search Results",
                    emptyrecords: 'No records to display',
                    deleteSelected: function (grid) {
                        alert("ci siamo");
                    }
                });
                jQuery("#pager").navGrid('#pager', { edit: false, add: false, del: true, search: false }, {}, {}, {});
                
            }
    

    I have a apply button which on click need to send data to controller the selected rows how to do it

    Friday, July 27, 2018 3:58 AM

All replies

  • User1520731567 posted

    Hi phmaspnet,

    According to your requirement, I suggest you could set editurl:

                    pager: "#pager",
    editurl: '/Home/EditCustomer',//when you edit and submit,it will jump to EditCustomer action viewrecords: true, multiselect: true, caption: "Search Results", emptyrecords: 'No records to display', deleteSelected: function (grid) {
    alert("ci siamo");
    }
    });
    jQuery("#pager").navGrid('#pager',
    {
    edit: true, //I use editor as an example.
    add: false,
    del: true,
    search: false
    }
    );

    And then define the same name action in controller:

     public string EditCustomer(Model model)
    {
    ....
    }

    How my demo works:

    So,we can send selected row values from a jqgrid to controller successfully.

    More details,you could refer to these links:

    https://www.c-sharpcorner.com/article/using-jqgrid-with-asp-net-mvc/

    http://www.trirand.com/blog/jqgrid/jqgrid.html

    Best Regards.

    Yuki Tao

    Monday, July 30, 2018 8:17 AM