SwVitaliy

Untitled

May 30th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. function tableGridRender( columns, data ) {
  2.  
  3. var rowIndex, columnIndex, table = jQuery( table || '<table><thead></thead><tbody><tbody></table>' ),
  4. row, coluntName, thead = '', tbody = '';
  5.  
  6. for ( columnIndex = 0; columnIndex < columns.lenght; columnIndex++ ) {
  7. thead += '<th>' + columns[columnIndex] + '</th>\n';
  8. }
  9. thead = '<tr> ' + thead + '</tr>';
  10.  
  11. for ( rowIndex = 0; rowIndex < data.length; rowIndex++ ) {
  12. row = '';
  13. for ( columnIndex = 0; columnIndex < columns.lenght; columnIndex++ ) {
  14. columnName = columns[columnIndex];
  15. if ( !data[rowIndex][columnName] )
  16. row += '<td>' + tableGridRender.EMPTY_CELL_VALUE + '</td>\n';
  17. else
  18. row += '<td>' + data[rowIndex][columnName] + '</td>\n';
  19. }
  20. tbody += '<tr>' + row + '</tr>';
  21. }
  22.  
  23. jQuery( thead ).appendTo( table.find('thead') );
  24. jQuery( tbody ).appendTo( table.find('tbody') );
  25.  
  26. return table;
  27. };
  28. tableGrid.EMPTY_CELL_VALUE = '<span class="xero_table_nothing">-</span>';
  29.  
  30.  
  31.  
  32. tableGridRender([
  33. 'AccountID', // Xero identifier
  34. 'Code', // Customer defined account code eg. 200
  35. 'Name', // Name of account
  36. 'Status', // See Account Status Codes
  37. 'Type', // See Account Types
  38. 'TaxType', // See Tax Types
  39. 'Description', // Description of Account. All accounts except bank accounts return this element
  40. 'Class', // See Account Class Types
  41. 'SystemAccount', // If this is a system account then this element is returned. See System Account types
  42. 'EnablePaymentsToAccount', // Boolean – describes whether account can have payments applied to it
  43. 'ShowInExpenseClaims', // Boolean – describes whether account code is available for use with expense claims
  44. 'BankAccountNumber', // Shown for bank accounts only
  45. 'CurrencyCode', // Shown for bank accounts only
  46. // 'ReportingCode', // shown if set (NZ Orgs only)
  47. // 'ReportingCodeName' // shown if set (NZ Orgs only)
  48. ],
  49. [{ 'AccountID': '245', 'Code': '3534', 'Status': 'jdgnjsd' },
  50. { 'AccountID': '245', 'Code': '3534', 'Status': 'jdgnjsd' }])
  51. .appendTo(jQuery('#xero_contact_in_wrap'));
Advertisement
Add Comment
Please, Sign In to add comment