andlio

Untitled

Apr 23rd, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define([
  2.     "dojo/_base/kernel",
  3.     "dojo/_base/declare",
  4.         "dojo/data/ItemFileWriteStore",
  5.     "dojox/grid/EnhancedGrid",
  6.     "dojox/grid/enhanced/plugins/IndirectSelection",
  7.    
  8. ], function(dojo, declare, itemFileWriteStore, grid) {
  9.    
  10.     dojo.experimental("widgets.grids.PlansGrid");
  11.    
  12.     var PlansGrid = declare("widgets.grids.PlansGrid", grid, {
  13.         structure:[
  14.             {
  15.                 name:'Versions', field:'_item', width: "auto",
  16.                 formatter:function(item){
  17.                     if(null==item) return;
  18.                    
  19.                     var value = item.version;
  20.                     if(item.published[0]==true) {
  21.                         value = value + " [P]";
  22.                     }
  23.                     if(item.submitted[0]==true){
  24.                         value = value + " [S]";
  25.                     }
  26.                    
  27.                     return value;
  28.                 }
  29.             }
  30.         ],
  31.        
  32.         store:null,
  33.         editable: false,
  34.         selectionMode:"single",
  35.         emptyMessage:"<i>No results<i/>",
  36.         constructor:function(){
  37.             this.store = new itemFileWriteStore({data:{items:[]}});
  38.         },
  39.         plugins: {indirectSelection: {headerSelector:false, width:"20px", styles:"text-align: center;"}},
  40.         /**
  41.          * Reset the grid data and selection.
  42.          * If data is null or empty, clear the store. Else, reset the store with the new data.
  43.          */
  44.         reset:function(/*array*/data){
  45.             /**
  46.              * Reset the data
  47.              */
  48.             if(null!=data && data.length>0){
  49.                 this.setStore(new itemFileWriteStore({data:{items:data}}));
  50.             }
  51.             else{
  52.                 this.setStore(new itemFileWriteStore({data:{items:[]}}));
  53.                 _this.showMessage(this.emptyMessage);
  54.             }
  55.             /**
  56.              * Reset the selection
  57.              */
  58.             this.selection.clear();
  59.         }
  60.     });
  61.    
  62.     return PlansGrid;
  63. });
Advertisement
Add Comment
Please, Sign In to add comment