2013-02-27 21 views
1

我正在使用jTable進行我的CRUD操作。但現在我想用JTable中創建對話框形式
如何使用jTable上傳文件在Asp.Net MVC中創建對話框?

How do i upload file using jTable create dialog? 

<div id="PersonTable" style="width: 580px; margin: auto;"></div> 

<script type="text/javascript"> 

    $(document).ready(function() { 

     //Prepare jtable plugin 
     $('#PersonTable').jtable({ 
      title: 'The Campus List', 
      actions: { 
       listAction: '/Home/CampusList', 
       deleteAction: '/Home/DeletePerson', 
       updateAction: '/Home/UpdatePerson', 
       createAction: '/Home/CreatePerson' 
      }, 
      paging: true, 
      fields: { 
       CampusId: { 
        key: true, 
        create: false, 
        edit: false, 
        list: true 
       }, 
       CampusName: { 
        title: 'CampusName', 
        width: '15%' 
       }, 
       CampusCode: { 
        title: 'CampusCode', 
        list: true 
       },Image: { } // for uploading file 
      } 
     }); 

     //Load person list from server 
     $('#PersonTable').jtable('load'); 
    }); 

</script> 

回答

0

默認情況下,jQuery的JTable中沒有文件上傳框上傳文件,但你可以用這樣的方式:

使用「輸入」屬性,字段的JTable範圍與返回 「格」 或文件上傳控制

如此:

fields: { 
      , 
      Attach: { 
       input : function (data){ 
       return "<input type='file' ... >"; // OR-----> 
       return "<asp:FileUpload .... >" ;// or-----> 
       } 
      }, 

但文件上傳需要完整的回發和文件上傳回發後的頁面上的所有文本區域清理,所以你需要JQuery和Iframe的Ajax上傳文件 jquery插件上傳它們。 您可以使用此地址爲完整的那樣:

How to display an IFRAME inside a jQuery UI dialog

How to make Asynchronous(AJAX) File Upload using iframe?

Issue with jQuery/iframe File Uploading Solution

相關問題