PDA

View Full Version : Dynamic add grid column property



subshark
2 Apr 2015, 4:46 AM
Hello!A create dynamicaly like this topic:http://www.sencha.com/forum/showthread.php?242594-Dynamic-grid-with-dynamic-modelIf I create json data like this:{"text":"Demo","dataIndex":"Field1","summaryType":"count","summaryRenderer":"function(value, summaryData, dataIndex) { return 0; } }summaryType property is work, but summaryRenderer not.And question is: how dynamicaly add, for example, summaryRenderer function to grid column?

tristan.lee
16 Apr 2015, 9:52 AM
Hi,

I'm sorry you're having trouble getting the summaryRenderer to work as expected. Looking at your code, is the JSON being returned in the response to configure the columns?



...
"metaData": {
"columns": [{

"text": "Demo",
"dataIndex": "Field1",
"summaryType": "count",
"summaryRenderer": "function(value, summaryData, dataIndex) {

return 0;

}"

}]
}
...

If your response contains column metadata, such as including a summaryRenderer function as a string, you will need to evaluate that response to set the renderer yourself. My suggestion would be to set a metachange listener on your store so that when the column definition changes, you can then evaluate your custom summaryRenderers for each column. I would also suggest that instead of returning then whole function definition, just return the function body as the value for summaryRenderer. This way you can create an anonymous function using your provided function body.

Here's a basic example:

lc5

Hope this helps,
Tristan

subshark
16 Apr 2015, 10:45 AM
Thanks!