Hi,
Could you please tell how to update an unbound column ? I've seen that with the 2016.1 version, there is method called 'setUnboundValueByPK' but i'm on the 2015.1 version and there is no indication in the documentation for that method. I guess its because its not available.
What could be your workaround for that ?
Regards
Hello Steeve,
To update unbound column, you have to use formula. Code Snippet:
columns: [{ headerText: "Total Price", key: "Total", dataType: "number", unbound: true, format: "currency", formula: function CalculateTotal(data, grid) { return data["UnitPrice"] * data["UnitsInStock"]; } }]
You can refer the following sample demonstrates how to add and configure unbound columns in igGrid
http://www.igniteui.com/grid/unbound-column
We do have setUnboundValues method in 15.1. setUnboundValues property sets unbound values for the unbound column with the specified key
http://www.igniteui.com/help/iggrid-unboundcolumns-method-reference
Please note setUnboundValueByPK property is not available in 15.1 but available in 15.2. All the method references available for unbound column iggrid is :
http://www.igniteui.com/help/api/2015.1/ui.iggrid#methods:setUnboundValues
Please let me know if I can assist you further.
Thank you for your answer.
Here is my context:
I have a unbound grid column set with a template property that displays an icon. I want to change the icon when the user clicks on the cell. The value of the icon does not depend on a value in the datasource, it depends more on an interaction with the user.
maybe i can't do that with an unbound column ?
What i've done so far is that i've added to all my objects in my datasource a new property with a value representing an icon, removed the unbound property of the cell and when the user clicks on the cell i call for an 'setCellValue' and update the icon. but i was hoping not to have things like that as i don't want to alter my datasource with that kind of property.
In the documentation , it says that with the method 'setCellValue' i should be able to update an unbound column. but i don't know how to do that as it does not rely on a specific value. Could you please help with that ?
In advance thank you for your help
setCellValue method is used to sets cell value for the specified cell it could be unbound column cell. It also creates a transaction and updates the UI. Functionality depends on autoCommit option of igGrid. If the specified cell is currently in edit mode, the function will set the desired value in the cell's editor instead.
You can find more information in the API doc here:
http://www.igniteui.com/help/api/2015.1/ui.iggridupdating#methods:setCellValue
You can use method as:
$("#grid10").on("iggridupdatingeditrowended", function (event, ui) {
var ColumnA = ui.values["ColumnA"];
var ColumnB = ui.values["ColumnB "];
var totalValue = (ColumnA * ColumnB)
//You can update the unbound column (Total) cell value as
$("#grid").igGridUpdating("setCellValue", ui.rowID, "Total", totalValue);
}
Rowid is a identifier of row such as value at primaryKey-column of igGrid. iggridupdatingeditrowended is a event which is raised when autoCommit of grid is not enabled and grid has pending transaction which may fail to be correctly rendered.
http://www.igniteui.com/help/api/2015.1/ui.iggridupdating#events:dataDirty
I have created a sample of unbound column with setCellValue method for your clear understanding. I am not sure how did you set icon in the sample. for more understanding about behavior of your requirement I would like to modify the sample and send me back.
Please let me know if I may be further assistance.