I have tried different ways to load the dropdown
from my DB to jqgrid
but the truth is that I do not get it, the idea is to show the dropwdown
and establish the selected
one that I bring it from my DB . Attached screenshot:
In responsible it should load my dropdown
, it does not do it however if it brings the data from my DB to fill said dropdown
:
To fill the grid, bring the following data
:
My code is the following:
var combobox_personal = $.ajax({
url:'/listadoPersonal',
async:false,
success:function(data, result){
if(!result){alert('erro ar cargar');}
}
}).responseText;
var sac_id=1;
var csrftoken = getCookie('csrftoken');
$("#grid_plan_accion").jqGrid({
url:'/selectPlanAccion',
postData: {
csrfmiddlewaretoken : csrftoken,
id_sac: sac_id,
},
datatype: 'json',
colNames: ['DETALLE<', 'PLAZO', 'RESPONSABLE', '<span class="badge bg-green">ACCIONES</span>'],
colModel: [
{ label: 'detalle_plan_accion', name: 'detalle_plan_accion', width: 170, sorttype: "string", editable: true, edittype:"text"},
{ label: 'plazo_plan_accion ', name: 'plazo_plan_accion', width: 40, sorttype: "string", editable: true, edittype: 'text' },
{name:'responsable_plan_accion_id',index:'responsable_plan_accion_id', width:100, editable:true, edittype: "select", formatter:'select',editoptions: { value: combobox_personal} },
{ name: "Acciones", formatter: buttonEliminarFormatter, width: 90, align:'center', search: false,
sortable: false, hidedlg: true, resizable: false, editable: false, viewable: false
}
],
rowNum: 10,
width:800,
height: 200,
//data:'mydata',
caption:'PLAN DE ACCION',
shrinkToFit: true,
pager: '#pager_plan_accion',
cellEdit: false,
cellsubmit: 'clientArray',
editurl: "clientArray",
});
I don't know what the error is maybe some suggestion...
you just have to change:
I will base my answer on when I used jqgrid a long time ago, and for those times they had specific formats for the creation of select option:
Your variable
combobox_personal
should have the following format:Chain type:
either
json type:
When you make the call to
'/listadoPersonal'
you can format the value that the query brings or return it already with some of those formats in the query.For example (assuming it
combobox_personal
's json, if not, parse it):