handle exception on store load if paging toolbar is used
[roojs1] / Roo / bootstrap / PagingToolbar.js
index 3e27e0c..5f6003b 100644 (file)
@@ -11,7 +11,7 @@
  
 /**
  * @class Roo.bootstrap.PagingToolbar
- * @extends Roo.bootstrap.NavSimplebar
+ * @extends Roo.bootstrap.nav.Simplebar
  * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
  * @constructor
  * Create a new PagingToolbar
@@ -44,13 +44,21 @@ Roo.bootstrap.PagingToolbar = function(config)
         this.bind(this.ds);
     }
     
-    this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
+    if (Roo.bootstrap.version == 4) {
+        this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
+    } else {
+        this.navgroup = new Roo.bootstrap.nav.Group({ cls: 'pagination' });
+    }
     
 };
 
-Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
+Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.nav.Simplebar, {
     /**
-     * @cfg {Roo.data.Store} dataSource
+     * @cfg {Roo.bootstrap.Button} buttons[]
+     * Buttons for the toolbar
+     */
+     /**
+     * @cfg {Roo.data.Store} store
      * The underlying data store providing the paged data
      */
     /**
@@ -130,12 +138,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         var _this = this;
         
-        Roo.log('PagingToolbar onRender!!!!!!!!!!!!!!!!!!!!');
-        Roo.log(this.buttons);
-        
         if(this.buttons){
             Roo.each(_this.buttons, function(e){ // this might need to use render????
-               Roo.factory(e).onRender(_this.el, null);
                Roo.factory(e).render(_this.el);
             });
         }
@@ -147,8 +151,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         this.first = this.navgroup.addItem({
             tooltip: this.firstText,
-            cls: "prev",
-            icon : 'fa fa-backward',
+            cls: "prev btn-outline-secondary",
+            html : ' <i class="fa fa-step-backward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click : this.onClick.createDelegate(this, ["first"]) }
@@ -156,8 +160,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         this.prev =  this.navgroup.addItem({
             tooltip: this.prevText,
-            cls: "prev",
-            icon : 'fa fa-step-backward',
+            cls: "prev btn-outline-secondary",
+            html : ' <i class="fa fa-backward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["prev"]) }
@@ -167,8 +171,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         var field = this.navgroup.addItem( {
             tagtype : 'span',
-            cls : 'x-paging-position',
-            
+            cls : 'x-paging-position  btn-outline-secondary',
+             disabled: true,
             html : this.beforePageText  +
                 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
                 '<span class="x-paging-after">' +  String.format(this.afterPageText, 1) + '</span>'
@@ -184,16 +188,16 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         //this.addSeparator();
         this.next = this.navgroup.addItem({
             tooltip: this.nextText,
-            cls: "next",
-            html : ' <i class="fa fa-step-forward">',
+            cls: "next btn-outline-secondary",
+            html : ' <i class="fa fa-forward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["next"]) }
         });
         this.last = this.navgroup.addItem({
             tooltip: this.lastText,
-            icon : 'fa fa-forward',
-            cls: "next",
+            html : ' <i class="fa fa-step-forward"></i>',
+            cls: "next btn-outline-secondary",
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["last"]) }
@@ -201,7 +205,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
     //this.addSeparator();
         this.loading = this.navgroup.addItem({
             tooltip: this.refreshText,
-            icon: 'fa fa-refresh',
+            cls: "btn-outline-secondary",
+            html : ' <i class="fa fa-refresh"></i>',
             preventDefault: true,
             listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
         });
@@ -225,7 +230,7 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
     // private
     onLoad : function(ds, r, o)
     {
-        this.cursor = o.params.start ? o.params.start : 0;
+        this.cursor = o.params && o.params.start ? o.params.start : 0;
         
         var d = this.getPageData(),
             ap = d.activePage,
@@ -253,8 +258,14 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
     },
 
     // private
-    onLoadError : function(){
+    onLoadError : function(proxy, o){
         this.loading.enable();
+        if (this.ds.events.loadexception.listeners.length  < 2) {
+            // nothing has been assigned to loadexception except this...
+            // so 
+            Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
+
+        }
     },
 
     // private