javascript - How do I separate display of data vs. usable data in an HTML table? -


this simplified scenario cut chase: have 1 webpage table of data in grams. can click on table header sort columns data, or click on rows highlight them. there's graph on page, , script on page pulls data out of table , uses data graph (this includes rows highlighted, highlights lines in graph @ same time).

now, i've taken values in table on 1000 grams, divided 1000 , show them kilograms, 1 column in table has mixture of grams , kilograms reading data. however, messes logic in all of above.

do think should hide machine-friendly (mf) data in hidden columns sort by, , display human-friendly (hf) columns? should include mf data in each table cell, hidden span tags? or worth decouple mf data on site? seems of these solutions involve ton of rewriting data retrieval, sorting, and/or graphing code. what's encapsulated approach?

consider storing data in javascript variable (not displayed on page @ all), , outputting data html using templating library. have @ jquery template start - http://api.jquery.com/category/plugins/templates/

edit: above api link doesn't give example. try this: http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-an-introduction-to-jquery-templating/


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -