Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind a dropdown list inside jqgrid row cell

I am implementing Jqgrid in my ASP.net MVC Application. I need to bind a dropdown list inside a grid column of Jqgrid.

I was not able to find any good solid code for reference how to do this..

can any one suggest how to do this..a complete example would be great .

like image 471
Sai Avinash Avatar asked Nov 18 '25 06:11

Sai Avinash


1 Answers

Try using editoptions

 jQuery('#grid').jqGrid({
        autowidth: true,
        autoheight: true,
        url : '',
        mtype : 'POST',
        colNames : [  'ID','State', 'Product'],
        colModel : [ {name : 'id',index : 'id',hidden:true,align:'center'},
                     {name : 'name',index :'name',width:200,
                                            sortable:true,
                                            align:'center',
                                            editable:true,
                                            cellEdit:true,
                                            edittype: 'select', 
                                            formatter: 'select',

                                            editoptions:{value: getAllSelectOptions()}
                     },
                     {name : 'product',index : 'product'},
                   ],
        rowNum : 10,
        sortname : 'name',
        viewrecords : true,
        gridview:true,
        pager : '#pager',
        sortorder : 'desc',
        caption : 'Setup',
        datatype : 'json'
    });


function getAllSelectOptions(){
 var states = { '1': 'Alabama', '2': 'California', '3': 'Florida', 
               '4': 'Hawaii', '5': 'London', '6': 'Oxford' };

  return states;

}

See here and check here for all

like image 129
Murali Murugesan Avatar answered Nov 20 '25 20:11

Murali Murugesan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!