Hi,
I have an igGrid, with column moving functionality and no data in the datasource. The datasource is a JSON object. Suppose I move a column when the grid is loaded (with no rows). Later when I add data to the datasource the grid data does not change according to the columns moved.
ex:
| A | B | C | D |
___________________________________
Column B moved to D
| A | D | C | B |
Data added to datasource:
A: 4, B: 3, C: 9, D: 8
shows the following grid
| 4 | 3 | 9 | 8 |
Please advice as to how to show data according to the new column format
Thank you
Hello Bhat,
Thank you for posting in our community.
Could you clarify which move type you have used for your grid?
I have created a sample where the ‘render’ move type is used so the DOM structure remains unchanged. The grid is just rendered with exchanged places of its columns. If you need detailed information on configuring column moving you might find useful the following resources: http://es.infragistics.com/help/topic/6010c2a0-e86b-42f5-9c5c-b9f9238ba7a0;
http://es.infragistics.com/help/topic/18ac9ebd-ab43-4974-9015-22c4a8cf51c6#_Ref345357842
I have also added the update feature in the sample in order to test the behavior with rows added when column positions have been already exchanged.
Feel free to modify the sample. If you have more questions or concerns please let me know.
Thank you for your reply.
However, I wanted to clarify that in the beginning, the datasource is empty, so is the grid. Then I move a column (with movetype : DOM or RENDER). Then I add data to the datasource and databind the grid. I am not adding rows with the update feature of the grid. I am adding rows to my datasource. At this time the header is moved to the new place but the column remains in its old position.
I hope this helps to understand my situation.
A possible reason causing this issue is mismatch between the key values in the igGrid column section and the JSON objects fields names (in bold in the code bellow).
columns: [
{ headerText: "Product ID", key: "ProductID", dataType: "number" },
{ headerText: "Product Name", key: "Name", dataType: "string" },
{ headerText: "Distributor", key: "Distributor", dataType: "string" },
{ headerText: "Quantity", key: "Quantity", dataType: "number"},
{ headerText: "Price", key: "Price", dataType: "number"}
],
products[0] = { "ProductID": 1, "Name": "Adjustable Race", "Distributor": "Danny Ltd.", "Quantity":12, "Price":23 };
It also should be noted that even in cases when data source is empty it is recommended data to be bound to the grid before applying functions such as column moving.
If you have more questions or concerns contact me again.
Thank you for your feedback.
I have created a case regarding your query. You could find this case and more detailed information regarding the corresponding issue in your active cases section of your Infragistics account. The path bellow is added for your reference:
http://es.infragistics.com/ -> Account -> Support Activity -> Active Cases.
All further updates concerning this case would be referred in this section.
Hi Dimka,
I worked with your example and my code and found out that if you add a column template to any of the columns, the column moving fails before databind. Attached is the sample
I am following up check if you have been able to resolve your issue. If you have more questions or concerns don’t hesitate to contact me again.
I have tested your scenario by using empty data source initially. I bind data after I have done column movements in advance and the records are again displayed in the correct order.
Note that in order to correctly reflect the changes (and record additions) done to the grid's data source, calling dataBind is required in this case. In order to allow me to examine this further it would be helpful to know if you are using a different version of Ignite UI in this case.
I have attached the modified sample.
Please let me know if this helps. If you have more questions don’t hesitate to contact me again.
Considering that I specify en empty datasource to the grid in the beginning. Later I populate the datasource as
Now how to reflect this data on the grid without rebinding or using igGrid('dataBind') ?