How can I change the cell values font color in edit more conditionally?
If you are attempting to do on load then the following should work:
Create a javascript function that returns the desired html, for example:
<script id="colTmpl" type="text/template"> {{if parseInt(${ID}) >0 }} ${REPORT_ID} {{else}} ${NAME} {{/if}} </script>
Define column settings for the desired column as follows:
{ headerText: "", key: "NAME", width: "30%", dataType: "string", template: $( "#colTmpl" ).html() }
This utilizes ifragistics column templating and templating engine, see the followings docs:
http://www.igniteui.com/help/creating-a-basic-column-template-in-the-iggrid
http://www.igniteui.com/help/igtemplating-overview
Hoe this helps, happy coding
Hello,
In case you wish to change the color of the editor inputs for when igGrid is in edit mode, you need to following two functions from the public API:
http://help.infragistics.com/jQuery/2015.2/ui.iggridupdating#methods:editorForKey
http://help.infragistics.com/jQuery/2015.2/ui.igtexteditor#methods:field
For example, if the editor for column "ProductName" should have its editor with red text color you should execute the following:
$("#grid1").igGridUpdating("editorForKey", "ProductName").igTextEditor("field").css("color", "red");
Please, have in mind that igGridUpdating creates the editors on demand - when the end-user first enters edit mode, therefore calling editorForKey before that will always return null.
I hope this helps!
Best regards,
Stamen Stoychev
Sure, you can use the findRecordByKey function to get the record being edited. In the context of the editRowStarted event handler the call will look like this:
ui.owner.grid.findRecordByKey(ui.rowID);
I do have a follow up question. I need to change the color in edit mode conditionally only. So I am doing this is "editRowStarted" event handler. I need to do based on other cell values (hidden). Is there a way to read all cell values when editRowStarted is raised? I could not find a way to do it. If not is there a work around for that?
Stamen - Thanks for getting back on this so quickly. It definitely works!
It looks like the editorForKey fix didn't make it for the December's SR which is causing your issue. Basically what is returned by editorForKey is the editor's DIV container and not the element it is actually initialized on so you can't directly call editor methods on it.
I've prepared a sample showing how to circumvent this as well as another approach based on the dynamic change of the editor's value as the end-user types (it may come useful for your application).
Please, have in mind that you will need to remove the ".find("span:first")" part from the editRowStarted handler when you choose to upgrade to a future SR or newer version of Ignite UI.
Let me know if you have any other questions or concerns! Thank you for using Infragistics forums!
Stamen - It is a string column and I am trying to initialize a text editor - igTextEditor like this...
$('#grid').igGridUpdating("editorForKey", "LastName").igTextEditor("field").css("color", "red");
I am using latest (Dec 11, 2015) service release. Not surewhat else am I missing.