Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1817

Converting from Yahoo! YUI Datatable

$
0
0
Recently, my boss and I decided to drop YUI altogether and go straight to jquery, that involves the datatable being dropped.
What I want to know is how to convert my existing datatables over to datatables.net
For example, YUI has formatters, which will format raw data into something else,
Does dt.net have this? I just kinda wish I had a YUI migration guide
      glbDtBugs = new Y.DataTable({
          colsresizable: true,
          columns: [
             {    
                 key: "id",
                 width: '55px',
                 formatter: '<input type="checkbox" name="item[]" value="{value}">',
                 label: '<input type="checkbox" id="id-all" value="all">',
                 allowHTML: true
             },
             {key:'inc_id', label:'#', sortable: true, width: '100px'},
             {key:'memo', sortable: true, resizable: true, width: '300px',
                 formatter: function(o){
                    var pixels = typeof(glbDtBugs.itsadtcr) == 'object' ? glbDtBugs.itsadtcr.getColumnWidthPx(2) : 166;
                    if (pixels < 166){
                       pixels = 166;
                    }
                    var fromUser = ClearBugs.users_assoc[o.data.created_by_user_id];
                    var assignedTo = '';
                    
                    assignedTo = UserIdsToUsernames(o.data._assigned_to_);
                    
                    if (assignedTo == ''){
                       if (o.data.assigned_to == 'all'){
                         assignedTo = 'ALL';
                       }else{
                         assignedTo = 'Anyone';
                       }
                    }    
                    
                    var cut_length = pixels/6.5;
                    var shortmemo = assignedTo + '« ';
                    
                    shortmemo += o.data.memo.substr(0, cut_length);
                    if (o.data.memo.length > cut_length + 3){
                       shortmemo += '...';
                    }else{
                       shortmemo = o.data.memo;
                    }
                    
                    if (fromUser && fromUser.username){
                       shortmemo += ' -' + fromUser.username;
                    }
                    if (o.data._bug_notes_ && o.data._bug_notes_.length > 0){
                       var count = 0;
                       for (var i = o.data._bug_notes_.length-1;i >= 0; --i){
                          count++;
                          if (count > 0){ shortmemo += '<br>'; }
                          shortmemo += getNoteShort(o.data._bug_notes_[i]);
                          
                          if (count >= 3){ break; }
                       }
                    }
                    return shortmemo;
                 },
                 allowHTML: true // Must be set or the html will be escaped
             },
             {label:'modified / created', key:'date_updated', allowHTML: true, sortable: true, formatter: function(o){
                
                var moment_created, moment_updated;

                moment_created = moment().utc(o.data.date_created);
                moment_updated = moment().utc(o.data.date_updated);
                if (!moment_created){ moment_created = moment().utc(); }
                if (!moment_updated){ moment_updated = moment_created; }
                
                if (moment_created.isAfter(mom_now)){ moment_created = mom_now; }
                if (moment_updated.isAfter(mom_now)){ moment_updated = mom_now; }
                
                var fromUser = ClearBugs.users_assoc[o.data.created_by_user_id];
                var s = '';
                s += moment_updated.fromNow();
                if (fromUser && fromUser.username){
                     s += ' by ' + fromUser.username;
                }
                s += ' / ';
                s += moment_created.fromNow();
                return '<span style="font-size: 10px">' + s + '</span>';
             }, allowHTML: true
             
             },
             {key:'kind', sortable: true},
             {key:'priority', sortable: true},
             {key:'status', sortable: true}
             
          ],
          data: data,
          scrollable: "y",
          height:"500px",
          width: "95%",
          // Optionally configure your table with a caption
          caption: "",

          // and/or a summary (table attribute)
          summary: "Bug List "/*,

          
          //selectable 
          highlightMode: 'row',
          selectionMode: 'row',
          selectionMulti: false     // allow multiple selections ...*/
      });


Viewing all articles
Browse latest Browse all 1817

Trending Articles