Aug 20, 2016, 1:21 AM
How to dynamically add either Combobox or DateField to Gridpanel Column Editor from code behind in MVC
Hi Guys,
I am Trying to create a grid with control created dynamically I used some code from this post
Uncaught ReferenceError: ComboBoxStore is not defined
I can see the control created but with de combobox I can't to set store or data.
Some body can help me with the dynamically creation of control,
Thanks
I am Trying to create a grid with control created dynamically I used some code from this post
http://forums.ext.net/showthread.php?17200-CLOSED-How-to-dynamically-add-either-Combobox-or-DateField-to-Gridpanel-Column-Editor-from-code-behind
this is my code X.GridPanel()
.ID("gpInteractivo")
//.Width(800)
.Height(400)
.Frame(true)
.Store(X.Store()
.ID("stIterativo")
.Model(X.Model()
.Fields(
X.ModelField().Name("nroseq").Type(ModelFieldType.Float),
X.ModelField().Name("nroitem").Type(ModelFieldType.Int),
X.ModelField().Name("idcampo").Type(ModelFieldType.String),
X.ModelField().Name("valor").Type(ModelFieldType.String),
X.ModelField().Name("tipocontrol").Type(ModelFieldType.String),
X.ModelField().Name("etiqueta").Type(ModelFieldType.String),
X.ModelField().Name("tipodato").Type(ModelFieldType.String),
X.ModelField().Name("formato").Type(ModelFieldType.String),
X.ModelField().Name("desconcepto").Type(ModelFieldType.String)
)
)
)
.ColumnModel(
X.Column().Text("Nro Seq").DataIndex("nroseq").Hidden(true),
X.Column().Text("Nro Item").DataIndex("nroitem").Hidden(true),
X.Column().Text("Id Campo").DataIndex("idcampo").Hidden(true),
X.Column().Text("Concepto").DataIndex("desconcepto").Width(200),
X.Column().Text("Etiqueta").DataIndex("etiqueta").Width(120),
X.Column().Text("Valor").DataIndex("valor").Width(120).ID("cEditable").Editor(X.TextField())
)
.SelectionModel(X.CellSelectionModel())
.Plugins(
X.CellEditing().Listeners(ls => ls.BeforeEdit.Fn = "edit")
)
and JS codevar edit = function (editor, e) {
var column = e.column;
ed = editor;
var tipocampo = e.record.data.tipocontrol;
switch (tipocampo) {
case "DAT":
column.setEditor(new Ext.form.DateField());
break
case "CBX":
// console.log('CBX');
column.setEditor(new Ext.form.ComboBox({
ID : "combod",
displayField: "value",
valueField: "id",
triggerAction: "all",
store: ComboBoxStore
}));
ComboBoxStore.on(
"beforeload",
function (recuperarData, options) {
options.params = {
urlgetlista: e.record.data.urlgetlista
}
},
null,
{
single: true
});
break;
}
};
var recuperarData = function (listaID) {
var bError = true;
console.log(listaID);
Ext.net.DirectMethod.request({
url: '/general/getData',
params: { urlgetlista: listaID },
success: function (result) {
console.log(result.data);
bError = false;
}
});
if (!bError) {
return result.data;
}
else {
return null;
}
}
and get this error Uncaught ReferenceError: ComboBoxStore is not defined
I can see the control created but with de combobox I can't to set store or data.
Some body can help me with the dynamically creation of control,
Thanks