Hello,
I am trying to use your iggrid component.
Below, my dataSource and my columns definition :
dataSource: [ { "ProductName": "ACACIA - ENV", "BrickId": 20152, "Fields": [ { "BrickId": 20152, "DictionaryId": 1617, "IsMultiValued": false, "Label": "Classe d actifs MKG niveau 1", "OrderIndex": 295, "PossibleValues": null, "Type": 95, "Value": { "m_Item1": 551, "m_Item2": "ValueToDisplay" }}, { "BrickId": 20152, "DictionaryId": 1618, "IsMultiValued": false, "Label": "Classe d actifs MKG niveau 2", "OrderIndex": 297, "PossibleValues": null, "Type": 95, "Value": { "m_Item1": 551, "m_Item2": "ValueToDisplay" }}, { "BrickId": 20152, "DictionaryId": 1619, "IsMultiValued": false, "Label": "Classe d actifs MKG niveau 3", "OrderIndex": 299, "PossibleValues": null, "Type": 95, "Value": { "m_Item1": 551, "m_Item2": "ValueToDisplay" }}] }]
columns: [{ "key": "ProductName", "headerText": "Nom produit" }, { "key": "Fields[0]", "headerText": "Classe d actifs MKG niveau 1", formatter: $scope.getValueFormater}, { "key": "Fields[1]", "headerText": "Classe d actifs MKG niveau 2", formatter: $scope.getValueFormater }, { "key": "Fields[2]", "headerText": "Classe d actifs MKG niveau 3", formatter: $scope.getValueFormater }]
I have a problem with the key. If I put "Fields", i have a value. But, if i put "Fields[0]", the value in the formatter function is undefined.
Is it possible to bind this complex JSON datasource with iggrid ?
What is the procedure to achieve this task?
Thanks for help.
Best regards.
Hello Caillard Nicolas,
Thank you for contacting Infragistics!
We received your support request concerning binding complex JSON data to the Grid, and this case has been assigned to me. Infragistics is dedicated to helping you solve this issue. Our team and I have done an initial review of your case and I will prepare a sample to try and implement the functionality you are seeking. I will get back to you by the end of the day tomorrow with more questions or information for you.
I wanted to ask you a couple questions which will help me clear up your question and find a solution for you. For each of your fields, do you want all of that data to be in one column? The way you have your data and columns set now, each Field will have its own column and all of the values in for example, Fields[0], will be in one cell of the grid. You will only have 1 row in your grid as well right now. However, if you are looking to have each attribute in Fields in a separate column, you will have 8 columns (excluding "Value") and 3 rows. In this scenario, you also run into issues because you have only one product name and 'Values' will give you issues. Please let me know the formatting of the data you are looking for and why the JSON is formatted this way please. Please don't hesitate to respond with more questions.
Hello Joe,
Thanks for your answer. It is the good solution.
Now, i am trying to add the updating feature on the grid and I have two problems :
Thanks for your help.
I was unable to reproduce the issue you are experiencing. Would it be possible for you to provide me with your sample? This would allow me to work with the exact behavior you're describing and would allow me to provide you with a solution as quickly as possible.
I look forward to hearing back from you.
Hi Joe,
You can reproduce the issue with your uploaded project.
I give you the igGrid object :
$("#grid").igGrid({
dataSource: data, //JSON Array defined above autoGenerateColumns: false, //responseDataKay: "Fields", columns: columnDefs, primaryKey: "ProductName", features:[{
name: "Updating", editMode: "row", enableAddRow: false, enableDeleteRow: false, showReadonlyEditors: false, showDoneCancelButtons: true, enableDataDirtyException: false, columnSettings: [{
columnKey: "ProductName", readOnly: true
}
]}]
When I click on the row, I can only edit the last column with "[object Object],[object Object],[object Object]".
Can you help me please?
I was able to reproduce the issue you were describing. As I mentioned in an earlier post, using the custom formatters for your columns and performing certain operations will cause issues. This is what we are now running into. In order to move forward and to avoid issues, I would recommend either of two paths.
The first recommendation I would make is to move from the igGrid to the igHierarchicalGrid. The data which you have is hierarchical and, therefore, not well suited for the igGrid. The igHierarchicalGrid on the other hand was made specifically for this type of data. I have attached a sample of your data in the igHierarchicalGrid to show you how much simpler it is to implement the displaying of this data. You will notice that the data is displayed with the use of autoGenerateColumns, a much easier solution than creating column formatters. You can find more information and samples on the igHierarchicalGrid at http://igniteui.com/hierarchical-grid/overview .
My other recommendation would be to make your data source flat. As I said earlier, the data you are feeding to the igGrid is hierarchical. The igGrid is made for flat data which is why we are getting the behavior we have been seeing. Converting to a flat data source would allow you to use the igGrid with no problem.
Whichever you choose, I will be more than happy to help along the way. Please let me know if you have any more questions, or if there is anything else I can assist you with.
Is there anything else I can assist you with on the matter? Please do not hesitate to contact me with more questions.