I have set the "required" property for columns in the columnSettings dynamically during initialization. When loading the igGrid (and adding a new row), I want to indicate those required fields with the cell colored in red. How can I do that?
Thanks!
hi Erica,
The editor options provide you with the functionality to set a custom theme.
Using the following code:
editorOptions: { theme: 'requiredCell' }
you may specify editor options for the columns that are required.
You may use also the following CSS to mark the cell with red border:
.requiredCell {border: 1px solid red !important;}
Hope that helps. Let me know if you are unable to use my comments and/or you need a specific sample.
regards
Lyubo
The cell is set to red depending on the columnSetting.required property value. Where should this logic be applied?
Can I have a sample specific for this?
I think I understood now your goal.
Find attached a sample that sets the red class to a cell marked as required in the column settings.
First - create a CSS class with the properties setting the cell in red:
The idea is to attach to the cell editing event and modify dynamicly based on that settings the editor class.
editCellStarting: function (e, ui) { var colSettings = ui.owner._colSet(null, ui.columnKey); if (colSettings && colSettings.required) { ui.editor.addClass("requiredCell"); } }
I've used for convenience internal function that gets the column settings, but you may write on your own cycle for looping the column settings, if you wish.
Also for convenience I've used your sample from one other post.
Please, let me know if something is still unclear.
Regards
Did you check the attachment and see how it's working with a checkbox column?
Any updates on this?
I already did the same:
var template = "<div class='requiredCell'>${" + column.key + "}</div>";
column.template = template;
But it displays differently for a checkbox column.
I'm sorry, I've provided you with a wrong code for the template. It should be looking like this:
col.template = "<div class='requiredCell'>${" + col.key + "}</div>";
Please check the new attachment and let me know if you have any questions.
Thanks Lyubo. Adding template as suggested works well with a text column. However, color does not show if the column contains a checkbox and a text of "<span style...>" was shown instead.
Please find the attached screenshot for the expected result that I want to achieve from your advice and the current behaviour with your suggested template.