2016-12-02 2 views
0

CORSを使用してasp.netコアwebapiプロジェクトからjqx.dataAdapterを埋め込み、データがJQWidgetsプロジェクトに渡って戻ってくるのを見ることができるまで私はDataAdapterを埋もうとします。 jqx.dataAdapter.recordsは埋め込まれませんが、jqx.dataAdapter.recordidsは8つの予期された行でいっぱいになります。CORSを使用してasp.net core webapiデータソースを持つdataAdapterを埋める

WebAPIのプロジェクト:

// GET api/changelog 
[HttpGet] 
public JsonResult Get() 
{ 
    IEnumerable<ApplicationChangeEntryExtension> results = null; 
    try 
    { 
     results = (from x in db.tblApplicationChangeLogEntries 
        select new ApplicationChangeEntryExtension() 
        { 
         ID = x.ID, 
         Application = x.Application, 
         Version = x.Version, 
         ReleaseCandidate = x.ReleaseCandidate, 
         IsReleaseCandidate = x.IsReleaseCandidate, 
         CustomerContent = x.CustomerContent, 
         InternalContent = x.InternalContent, 
         DevDate = x.DevDate, 
         TestDate = x.TestDate, 
         PreReleaseDate = x.PreReleaseDate, 
         PreProductionDate = x.PreProductionDate, 
         DeployDate = x.DeployDate 
        }); 
    } 
    catch(Exception exc) 
    { 
     Console.WriteLine(exc); 
    } 
    return Json(results); 
} 

jqwidgetsプロジェクト:

$('#ChangeLogLink').on('click', function (event) { 
    $('#popupwindowChangeLog').jqxWindow({ 
     showCollapseButton: false, 
     showCloseButton: true, 
     draggable: false, 
     isModal: true, 
     autoOpen: false, 
     height: 500, 
     width: 850, 
     theme: _Theme, 
     modalOpacity: 0, 
     initContent: function() { 
      var _source = { 
       type: 'GET', 
       datatype: 'json', 
       root: 'results', 
       datafields: [ 
        { name: 'ID', type: 'integer' }, 
        { name: 'Application', type: 'string' }, 
        { name: 'Version', type: 'string' }, 
        { name: 'ReleaseCandidate', type: 'integer' }, 
        { name: 'IsReleaseCandidate', type: 'boolean' }, 
        { name: 'CustomerContent', type: 'string' }, 
        { name: 'InternalContent', type: 'string' }, 
        { name: 'DevDate', type: 'date' }, 
        { name: 'TestDate', type: 'date' }, 
        { name: 'PreReleaseDate', type: 'date' }, 
        { name: 'PreProductionDate', type: 'date' }, 
        { name: 'DeployDate', type: 'date' } 
       ], 
       url: 'http://localhost:2512/api/changelog', 
       id: 'ID' 
      }; 

      var _dataAdapter = new $.jqx.dataAdapter(_source); 

      $("#divChangeLogListContainer").html('<div id="divChangeLogList"></div>'); 
      $("#divChangeLogList").jqxDataTable({ 
       source: _dataAdapter, 
       width: '100%', 
       height: '100%', 
       theme: _integronTheme, 
       pageable: true, 
       pagerButtonsCount: 5, 
       sortable: true, 
       filterable: false, 
       columnsResize: true, 
       pageSize: 25, 
       altRows: true, 
       columns: [ 
        { text: 'ID', datafield: 'ID'}, 
        { text: 'Application', datafield: 'Application'}, 
        { text: 'Version', datafield: 'Version'}, 
        { text: 'Release Candidate', datafield: 'ReleaseCandidate'}, 
        { text: 'Is Release Candidate', datafield: 'IsReleaseCandidate'}, 
        { text: 'Customer Content', datafield: 'CustomerContent'}, 
        { text: 'Internal Content', datafield: 'InternalContent'}, 
        { text: 'Customer Order #', datafield: 'CustomerOrderID'}, 
        { text: 'Dev Date', datafield: 'DevDate', cellsformat: 'M/d/yyyy', cellsalign: 'center', align: 'center'}, 
        { text: 'Test Date', datafield: 'TestDate', cellsformat: 'M/d/yyyy', cellsalign: 'center', align: 'center'}, 
        { text: 'PreRelease Date', datafield: 'PreReleaseDate', cellsformat: 'M/d/yyyy', cellsalign: 'center', align: 'center'}, 
        { text: 'PreProduction Date', datafield: 'PreProductionDate', cellsformat: 'M/d/yyyy', cellsalign: 'center', align: 'center'}, 
        { text: 'Deploy Date', datafield: 'DeployDate', cellsformat: 'M/d/yyyy', cellsalign: 'center', align: 'center'} 
       ] 
      }); 
     } 
    }); 
    $('#popupwindowChangeLog').jqxWindow('open'); 

}); 

答えて

0

私は、データアダプタを作成し、またはそのdataBind()メソッドを呼び出すときにautoBindパラメータを逃すと思います。

また、非同期読み込みを使用してデータテーブルを作成することもできます。

jqwidgets.com

+0

おかげで、各メソッドの例を参照してください、ここでは何も私の最終結果を変更しません。 dataTableはまだデータを読み込まず、空の行だけを読み込みます。 –

関連する問題