code_junkie

How to make YUI datasource parse Null values in the dataset

Nov 14th, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var columnDescription =
  2. [
  3. {key:'Requirements'},
  4. {key:'abc'},
  5. {key:'xyz'}
  6. ];
  7.  
  8. var dataSrcSample = new YAHOO.util.FunctionDataSource(getDataGrid);
  9. myDataSource.connMethodPost = true;
  10. myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
  11. myDataSource.responseSchema = {
  12. fields:['Requirements',
  13. {key:'abc',parser:YAHOO.util.DataSource.parseString},
  14. {key:'xyz',parser:YAHOO.util.DataSource.parseString}]
  15. };
  16.  
  17. YAHOO.example.sampleTable = function()
  18. {
  19. var columnDesc=columnDescription;
  20. var myDataSource = dataSrcSample;
  21. var oConfigs =
  22. {
  23. width:'100%'
  24. };
  25.  
  26. var myDataTable = new YAHOO.widget.DataTable("tableContainerDiv",
  27. columnDesc,
  28. myDataSource,
  29. oConfigs);
  30. }();
  31.  
  32. function getDataGrid()
  33. {
  34. //calls backend and gets the data
  35. }
  36.  
  37. function parseNull(value) {
  38. // This exact logic may be incorrect, depends on what you get for value in the null case
  39. if (value=='null') {
  40. return null;
  41. }
  42. YAHOO.util.DataSource.parseString(value);
  43. }
  44.  
  45. {key:'abc',parser:parseNull}
Add Comment
Please, Sign In to add comment