This is a migrated thread and some comments may be shown as answers.

Grid with template error (Uncaught ReferenceError: sum is not define)

2 Answers 1039 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 Jun 2012, 01:45 PM
I'm using kendo 2012.1.515 and receiving an error when using a grid that contains columns and a footer template that has an aggregate defined. The error appears once all of the rows are deleted from the grid (click the delete button to see this in action in my jsfiddle examples below).

Browser: latest version of Chrome but it also appears in IE9

jsfiddle that displays the issue: http://jsfiddle.net/MLYdR/11/ (Uncaught ReferenceError: sum is not defined)

 I was receiving another error when referencing 2012.1.322: http://jsfiddle.net/MLYdR/9/ (Uncaught TypeError: undefined has no properties)

Any info or a work around would be greatly appreciated.

Thanks,
Chris

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 25 Jun 2012, 12:58 PM
This was resolved in the Q2 2012 Beta Release of Kendo UI.

http://jsfiddle.net/MLYdR/12/
http://jsfiddle.net/MLYdR/13/

0
joshua
Top achievements
Rank 1
answered on 15 Aug 2012, 05:28 PM
This is still not fixed I did a detailed walk through of your code and found this:

Let me start by saying I am honestly trying to help. So unlike many of the other posts i have read I would rather you listen and not just tell me we are wrong... because what im saying is in both senerios below is out side of the programmer control, and the template your built is well not ready for them.

In short the template (though great it is) for the data-grid is deeply flawed and reliant on perfect data or it fails. I am of the general mind set that the templates should work for the most messed up senerior's, but taking that back a step they should work for simple ones also. 

I also reference line numbers in the keno.web.js file

I have mocked up this example based off of your example. 
Condensed json data call: (Not returning null values)  http://jsfiddle.net/3zhqx/1/ 

Resaults: Uncaught ReferenceError: age is not defined 

Pulling data from other locations where you cant controll the formatting of the incoming data json data call: (IE Web 2.0)
 http://jsfiddle.net/EyCZd/2/  No Error but the template does not pull the error.

http://jsfiddle.net/qqskQ/3/ 
Uncaught ReferenceError: Name is not defined  


Resolustion: (Many Options,but all have costs...)
21309: 
 rowTemplate = kendo.template(rowTemplate, settings);

This builds the row template:

21333-21395 Template builder.
In this you reference the data with a with clause and then fill those values from the data. True this is the most expedient but also the most fragile. It causes both of the error above.  It means that the system can not handle for columns that you cant control the naming of, or if the json data is missing a column or if the column is puposly missing to save space bacause its nulle.

Jquery ran into the smae issue and return null in the exsampel. http://api.jquery.com/template-tag-if/  read the big header at the top...

To fix this you can loop through the columsn try to ge the data and then build a html set acordingly. Personaly this may seam longer , but the computed total cyles would be less then the total computed cost fo the next one item. The last option is up for debate. 

The second option is to add to the current builder a way to check for undefined opjects... this is exceedingly difficult seeing as to how tightly coupled and fagle that particular line of code is. 

This is how they handled for it in another template in your code:
10675  { data.title || ""} insted of with(data)...... e(title)

I tried to manually do this, but i have only been a java programmer for two months and lack all the verbiage needed to write the code well... that and it was 3 in the morning. 

The third option is what i had to do out side of the control, but its an unneeded mess fix that makes me pass a 1/3 more data to handle for this. Almost a deal breaker for me.

I had to fix all incomimng feed and gerate a fixed column name and colection, and I had to make sure all my jason and my feed have every  row  have every column.... when dealing with massive data sets that sucks both on bandwidth and cpu. and column in the. That is why i went mvvm in the first place to deffer costs...

So back to the fix you could when binding the data... I think 4601 or there about... check to make sure each line has every row and fit it in as null if it does not. the reason this may be the fastes is because your already looping through all the data on every call and sooooo you can add in at 4723 I think.... that would allow you to add in a null object with the correct name into the data.

I think the last one is the right idea but i ren out of time to trouble shoot the issue nay more.

The use case is this:
User is either pulling data from a myriad of sources and union the data so the rows may not always match, but thats ok because its web 2.0... say netflix and blockbuster feeds... bad example you can shoot it down but the need is there.

user is managing lots of data and needs to save bandwidth and cpu by processing less data. (got to love and hate the cloud.) so he can not always send null filed in json.

User is geting data from a source that is not known or well defined, and needs to pass it right to the client... for whatever reason..  or user is getting dynamic columns from data and may not know what the columns are or how well they are formatted...


Hope this helps.

Sorry for the spelling im busy got to run.

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
joshua
Top achievements
Rank 1
Share this question
or