How can get Grid combox option data from mysql table using datacollection
Unfortunately such scenario is not supported.
I can only suggest you to fetch the options data from your backend beforehand, and use the response in the grid config.
Something like:
dhx.ajax.get(url).then(function(response){
new dhx.Grid(cont,{
{
id: "combo_col",
header: [{ text: "combo" }],
editorType: "combobox",
options:response}
})
})
Thanks for your reply. The grid is in a layout when I use your code in say the container is not defined. But the grid works normaly outside the ajax command but i need to hard code the options.
The suggested solution is not strict to the grid initalization way. So, in case of initialization to layout cell it would be:
dhx.ajax.get(url).then(function(response){
grid = new dhx.Grid(null,{
{
id: "combo_col",
header: [{ text: "combo" }],
editorType: "combobox",
options:response}
})
layout.getCell("grid_cell").attach(grid)
})
thanks again for your reply. The grid now shows in the layout but now the problem is this grid is linked to another grid. I use an grid.events.on(“afterSelect” from the first grid and get its record number and get the data from the server using const defectDataUrl = defectData.php?report_id=${rowData.id}
;
console.log("defectDataUrl is" , defectDataUrl)
defectGrid.data
.load(defectDataUrl)
.then(() => {
console.log("Defect data loaded for Report ID:", rowData.id);
})
.catch((error) => {
console.error("Error loading defect data:", error);
});
}
Before the ajax command the code worked but now it get TypeError: Cannot read properties of undefined (reading ‘data’)