webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Insert an image according to the field value #207

Open ticelso opened 3 years ago

ticelso commented 3 years ago

Hello people. I have a field in my database called 'status_fun' that is being loaded normally inside the grid. In the images directory I put two images in the [images / flags] directory named '1.png' and '2.png'. I need to show these images according to the value of the 'status_fun' field which can be '1' or '2', for that I'm using the example:

DatabaseGrid.prototype.initializeGrid = function(grid) { var self = this; // render for the action column grid.setCellRenderer("action", new CellRenderer({ render: function(cell, id) { cell.innerHTML+= "<i onclick=\"datagrid.deleteRow("+id+");\" class='fa fa-trash-o red' ></i>"; } })); getColumn("status_fun").cellEditor.minWidth = 105; setCellRenderer("status_fun", new CellRenderer({ render: function (cell, value) { cell.innerHTML = value ? "<img src='" + image("flags/" + value.toLowerCase() + ".png") + "' alt='" + value + "'/>" : ""; cell.style.textAlign = "center"; } })); grid.renderGrid("tablecontent", "testgrid"); };

The error returned is that the column 'status_fun' does not exist. How do I make the column available so I can make this change?