Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table dojoType="dojox.grid.DataGrid">
- <thead>
- <tr>
- <th field="id">ID</th>
- <th field="contact.name">Name</th>
- <th field="contact.tel">Telephone</th>
- <th field="contact.birthdate.time">Birthday</th>
- </tr>
- </thead>
- </table>
- [{
- 'id':1,
- 'contact':{
- 'name':'Doh',
- 'firstname':'John',
- 'tel':'123-123456',
- 'birthdate':{
- 'javaClass':'java.sql.Timestamp',
- 'time':1234567893434}}
- }]
- <table dojoType="dojox.grid.DataGrid">
- <thead>
- <tr>
- <th field="id">ID</th>
- <th field="contact" get="myGrid.getContactName">Name</th>
- <th field="contact" get="myGrid.getContactTel">Telephone</th>
- <th field="contact" get="myGrid.getContactBirthdateTime">Birthday</th>
- </tr>
- </thead>
- </table>
- myGrid.getContactName = function(colIndex,item){
- return item.name;
- };
- myGrid.getContactName = function(colIndex,record){
- if(record)return record.contact.name;
- else return null;
- };
- dgc._Base.markupFactory = function(node, cellDef){
- var d = dojo;
- ...
- var comparator = d.trim(d.attr(node,"comparator")||"");
- if(comparator){
- cellDef.comparator = dojo.getObject(comparator);
- }
- ...
- }
- getSortProps:function(){
- ...
- return[{attribute:c.field,descending:desc,comparator:c.comparator}];
- }
- function execute(array){
- // execute the whole query, first we filter
- var results = dojo.filter(array, query);
- // next we sort
- if(options && options.sort){
- results.sort(function(a, b){
- for(var sort, i=0; sort = options.sort[i]; i++){
- var aValue = a[sort.attribute];
- var bValue = b[sort.attribute];
- if (aValue != bValue) {
- // changed Part start
- if(options.sort[i].comparator){
- return !!sort.descending == options.sort[i].comparator(aValue,bValue) ? -1 : 1;
- }
- else{
- return !!sort.descending == aValue > bValue ? -1 : 1;
- }
- // changed Part end
- }
- }
- return 0;
- });
- }
- ...
- return results;
- }
- ...
- <td field="myArray" get="getsNameFromArray" comparator="comparesNames">Name</td>
- ...
- compareNames = function(a,b){
- return a.name > b.name;
- }
- getNamesFromArray= function(idx,record){
- return record.myArray.name;
- }
- ...
- <th field="contact" get=myGrid.getContactName>Name</th>
- ...
Add Comment
Please, Sign In to add comment