2014-09-23 63 views
0

我是bootstrap的新手,我們所有的用戶界面大部分都是KendoGrid'sKendoGrid內部引導

我們想將KendoGrid嵌入引導程序的Modal Window之內,並試着在Kendo Grid in Bootstrap 2 or 3 Modal - IE Filters do not work中發佈的代碼下面。但在這裏,close按鈕和header不在Modal窗口中,看起來很奇怪。我認爲這是因爲bootstrap css版本。當試用bootstrap_2.3.2.min.css時,解決了這個問題。但我們應該使用v3.2.0。請讓我知道是否有任何解決方案。

http://jsbin.com/yiyon

<div class='modal fade' id='myModal'> 
    <div class='modal-header'> 
     <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button> 
     <h3><strong>$heading</strong></h3> 
    </div> 
    <div class='modal-body'> 
     <div id="grid"></div> 
    </div> 
</div> 

<script> 
    var products = [{ 
     ProductID: 1, 
     ProductName: "Chai", 
     SupplierID: 1, 
     CategoryID: 1, 
     QuantityPerUnit: "10 boxes x 20 bags", 
     UnitPrice: 18.0000, 
     UnitsInStock: 39, 
     UnitsOnOrder: 0, 
     ReorderLevel: 10, 
     Discontinued: false, 
     Category: { 
      CategoryID: 1, 
      CategoryName: "Beverages", 
      Description: "Soft drinks, coffees, teas, beers, and ales" 
     }, 
     popupPermission: true, 
     somethingElsePermission: false 
    }, { 
     ProductID: 2, 
     ProductName: "Chang", 
     SupplierID: 1, 
     CategoryID: 1, 
     QuantityPerUnit: "24 - 12 oz bottles", 
     UnitPrice: 19.0000, 
     UnitsInStock: 17, 
     UnitsOnOrder: 40, 
     ReorderLevel: 25, 
     Discontinued: false, 
     Category: { 
      CategoryID: 1, 
      CategoryName: "Beverages", 
      Description: "Soft drinks, coffees, teas, beers, and ales" 
     }, 
     popupPermission: true, 
     somethingElsePermission: true 
    } 
    ]; 

    columnsettings = [ 
      "ProductName", 
      { 
       field: "UnitPrice", 
       title: "Unit Price", 
       format: "{0:c}", 
       width: "130px" 
      }, 
      { 
       field: "UnitsInStock", 
       title: "Units In Stock", 
       width: "130px" 
      }, 
      { 
       field: "Discontinued", 
       width: "130px" 
      } 
    ]; 

    var gridDataSource = new kendo.data.DataSource({ 
     data: products, 
     schema: { 
      model: { 
       id: "uid", 
       fields: { 
        ProductName: { type: "string" }, 
        UnitPrice: { type: "number" }, 
        UnitsInStock: { type: "number" }, 
        Discontinued: { type: "boolean" } 
       } 
      } 
     }, 
     sort: { 
      field: "", 
      dir: "desc" 
     }, 
     pageSize: 50 
    }); 



    $(document).on('click', '#openModal', function() { 
     $('#myModal').modal('show'); 
     if (!$('#grid').data('kendoGrid')) { 
      createGrid(); 
     } 
    }); 

    function createGrid() { 
     $('#grid').kendoGrid({ 
      dataSource: gridDataSource, 
      scrollable: true, 
      reorderable: true, 
      resizable: true, 
      pageable: { 
       refresh: true, 
       pageSizes: [50, 100, 200] 
      }, 

      filterable: { 
       extra: false, 
       operators: { 
        string: { 
         contains: "Contains", 
         startswith: "Starts with" 
        }, 
        number: { 
         lt: "Is less than", 
         eq: "Is equal to", 
         gt: "Is greater than" 
        }, 
        date: { 
         lt: "Is less than", 
         eq: "Is equal to", 
         gt: "Is greater than" 
        } 
       } 
      }, 
      sortable: { 
       mode: "single", 
       allowUnsort: false 
      } 
     }); 
    } 

</script> 

回答

1

事實上,你已經忘記了嵌入有兩個divs內容:

<div class='modal fade' id='myModal'> 
    <div class='modal-dialog'> <!-- First div for setting the dialog --> 
    <div class='modal-content'> <!-- Second div for setting the content --> 
     <div class='modal-header'> 
     <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button> 
     <h3><strong>$heading</strong></h3> 
     </div> 
     <div class='modal-body'> 
     <div id="grid"></div> 
     </div> 
    </div> 
    </div> 
</div> 

我已經更新您的jsbin:http://jsbin.com/hujomaxituqo/1/

+0

謝謝,我不知道如何它與舊版本一起工作.. – Interstellar 2014-09-23 14:18:50

+0

你可以看看這裏的舊文檔:http://getbootstrap.com/2.3.2/javascript.html#modals - >標記只是在v2.3.2和v3.2.0之間更新... – 2014-09-23 14:21:04

+0

Bootstrap的2 - > 3遷移文檔中還包含了此(以及許多其他更改):http://getbootstrap.com/migration/ – cvrebert 2014-09-23 18:13:37