2012-11-27 39 views
8

मेरे पास डेटासोर्स में दिनांक फ़ील्ड के साथ एक केंडो ग्रिड है। फ़ील्ड को प्रदर्शित करते समय मैं यूके दिनांक प्रारूप 'डीडी/एमएम/yyyy' में दिनांक प्रदर्शित करने के लिए एक टेम्पलेट का उपयोग करता हूं। समस्या फ़िल्टर करते समय समस्या है, मुझे नहीं पता कि यूके प्रारूप में दिनांक फ़िल्टर कैसे प्रदर्शित करें।केंडो ui ग्रिड डेटासोर्स फ़िल्टर दिनांक प्रारूप

मेरी एक और समस्या यह है कि मेरे पास कोई अन्य समय नहीं है, बस डेटटाइम प्रकार नहीं है, इसलिए केवल तारीखों द्वारा फ़िल्टर नहीं किया जा सकता है।

किसी भी मदद या विचारों की सराहना की जाएगी।

(cshtml)

<script type="text/javascript"> 
$(document).ready(function() { 
    var date = new Date(); 
    var dateString = date.getMonth()+1 + "/" + date.getDate() + "/" + date.getFullYear(); 
    var url = '@Url.Action(AccountTypeController.GetAllocationGridData, new {id = Model.Id})'; 

    var dataSource = new kendo.data.DataSource({ 
     serverPaging: true, 
     serverSorting: true, 
     serverFiltering: true, 
     pageSize: 10, 
     transport: { 
      read: { 
       type: 'post', 
       dataType: 'json', 
       url: url 
      }, 
      parameterMap: function(options) { 
       if (options.filter) { 
        for (var i = 0; i < options.filter.filters.length; i++) { 
         if (options.filter.filters[i].field == 'Start' || options.filter.filters[i].field == 'End') { 
          options.filter.filters[i].value = kendo.toString(options.filter.filters[i].value, "MM/dd/yyyy"); 
         } 
        } 
       } 
       return options; 
      } 
     }, 
     schema: { 
      data: 'Data', 
      total: 'Count', 
      model: { 
       id: 'Id', 
       fields: { 
        Id: { type: 'number' }, 
        Start: { type: 'date' }, 
        End: { type: 'date' }, 
        Allocation: { type: 'number' } 
       } 
      } 
     }, 
     sort: { 
      field: "Start", 
      dir: "asc" 
     }, 
     filter:{ 
      logic: "and", 
      filters: [ 
       { 
        field: "End", 
        operator: "gt", 
        value: dateString 
       } 
      ] 
     } 
    }); 

    $('#account-allocation').kendoGrid({ 
     height: 383, 
     dataSource: dataSource, 
     columns: [ 
      { 
       field: 'Start', 
       title: 'Start Date', 
       template: '#= kendo.toString(Start,"dd/MM/yyyy HH:mm") #' 
      }, 
      { 
       field: 'End', 
       title: 'End Date', 
       template: '#= kendo.toString(End,"dd/MM/yyyy HH:mm") #' 
      }, 
      { 
       field: 'NoSpaces', 
       title: 'Number of Spaces', 
       filterable: false 
      }, 
      { 
       field: 'Id', 
       filterable: false, 
       title: 'Actions', 
       template: '<a class="link-lightbox" href="@Url.Action(AccountTypeController.UpdateAllocationAction1, AccountTypeController.Name)/#= Id #"><img src="@Url.Content("~/Content/img/grid-update.png")" alt="Update"/></a>', 
       width: 75 
      } 
     ], 
     filterable: true, 
     sortable: false, 
     scrollable: false, 
     pageable: true   
    }); 
</script> 

<div class="panel panel-w"> 
    <h2>@Model.Name Allocations 
      <a href="@Url.Action(AccountTypeController.SetAllocationAction1, new { id = Model.Id })" class="button link-lightbox"><span class="edit">Set Account Type Allocation</span></a> 
    </h2> 
    <div id="account-allocation"></div> 
</div> 
+0

इसके अलावा, आप यहाँ देखने के लिए कोशिश कर सकते: http://stackoverflow.com/questions/28232575/kendoui-grid-filter-date-format –

उत्तर

9

पहले JavaScript फ़ाइल अंग्रेजी संस्कृति के लिए इसी में शामिल हैं यह आंशिक दृश्य है:

<script src="http://cdn.kendostatic.com/2012.2.710/js/cultures/kendo.culture.en-GB.min.js"></script> 

फिर kendo.culture आह्वान वर्तमान संस्कृति स्थापित करने के लिए:

kendo.culture("en-GB"); 

केंडो ग्रिड स्वचालित रूप से 'डीडी/एमएम/वाई वाई' प्रारूप का उपयोग करेगा।

वैश्विककरण के साथ केंडो यूआई सौदों के बारे में अधिक जानकारी documentation में मिल सकती है।

यहाँ एक लाइव डेमो है: http://jsbin.com/onetol/1/edit

+0

काम किया पूरी तरह से। धन्यवाद! –