سؤال

I am dynamically building the colModel for my jQGrid using fields from a DataTable. Nearly all of it works as I hoped. However, I am unable to use a custom summaryType because I can't serialize without the quotes and jQgrid doesn't look for the method if in quotes.

Presently, if I don't remove the ", I get the following error when loading the grid:

Uncaught jqGrid Grouping No such method: mysum

If I remove the quotes in the table, I get the following error when serializing:

Invalid JSON primitive: mysum.

What is the best way to tackle this problem?

هل كانت مفيدة؟

المحلول

You will probably have to create a solution in the view using javascript. If you manually serialize the colModel to send to the view, you will have to manually deserialize. You will not be able to parse it with a JSON parser because it will not be a valid JSON string.

One possible approach would be to use eval() on the string like this:

myObject.property = eval("mysum");

It should replace the string with the function. I am not sure if it meets your needs, but will avoid both errors you listed above.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top