Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid using same dataField for multiple columns

I have a jqGrid which gets its data in JSON format by setting the url parameter.

Is it possible to create multiple columns and let them display the same property of the JSON response?

For example in one column i want to display the data formatted in one way, in another column i want to display the data in another way.

like image 683
Jens876 Avatar asked Mar 03 '26 03:03

Jens876


1 Answers

Yes, it's possible. The exact implementation depends from the format which you use in the server response. If you use jsonReader: { repeatitems: false } then one can use jsonmap property in colModel. jqGrid uses jsonmap instead of name during reading of response from the server. So the solution of your problem could be about the following

colModel: [
    ...
    { name: "mainColumn" },
    ...
    { name: "duplicate1OfMainColumn", jsonmap: "mainColumn" },
    ...
    { name: "duplicate2OfMainColumn", jsonmap: "mainColumn" },
    ...
]

Of case you can define different formatter for every from the columns.

If one have to use datatype: "xml" instead of datatype: "json" then one can use xmlmap instead of jsonmap.

like image 60
Oleg Avatar answered Mar 05 '26 15:03

Oleg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!