This is going to be hard to conceptualize so bear with me.
I have a model that contains some static customer data. Within this model, there are a list of priorities that need to be represented in a grid so mass maintenance can be applied to wide range of customers at once. Here's the model object:int CustomerId (readonly)string AccountNumber (readonly)string AccountName (readonly)string[] PrioritiesThe grid will be represented as follows:CustomerId | AccountNumber | AccountName | Priority 1 | Priority 2 | Priority 3 | Priority N...We want to be able to change the priorities on a mass level so our employees don't have to manage each record one at a time.
Question: How can I PIVOT the property 'Priorities', so it can be represented as a dynamic column in an igGrid? The number of columns = the max count of priorities in the collection of models. Also the index of the priority in the property represents the column it belongs too.I am very open to alternate suggestions and designs. How can I better represent this action?
hi Daniel,
one approach would be to make the Priorities a child grid of every customer. So you basically you can have a 1:n relationship, and every customer can have a list of priorities, that will be rendered vertically as a child grid, as opposed to horizontally, as part of the same list. Note that the grid cannot have different columns for _every_ separate record. Here is an example of the hierarchical jQuery grid, which achieves this scenario (so basically the "Properties" property in your model will hold the child data):
http://ko.infragistics.com/products/jquery/sample/hierarchical-grid/different-data-sources
Another approach would be to flatten your data, so you will end up with a list of objects, where the number of properties will be variable. So for the first object in the list you can have N props (fixed + number of priorities), the second object may have N + X props, etc. IN that case you need to define the maximum priorities any record may have, so your grid columns will be always equal to that max number. If an object has less priorities, it will render empty values in the rest of the columns. Say a customer has 2 priorities, but the max is 4 priorities, so that customer will render values in the Priority1 and Priority2 columns but the Priority3 and priority4 cols will be empty.
Let me know if this helps. Thanks,
Angel
So I went the latter approach and it seems to be working just fine. We'll just have an application constraint which is okay at the moment. We don't foresee an infinite number as originally thought.
Thanks,
Please let me know if you have any other questions about this. Thanks,