andlio

Untitled

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