Good night! I'm going in kendo ui Grid schema model and a field of type date, but that is happening on the filter settings when I click is just showing operators that work with string, looking like he just identidica this field as a string! Can anyone help me?
<script>
$(document).ready(function(){})
function getData(page)
{
data = page.split("||");
//data = $.parseJSON(page);
//alert(data.toSource());
//alert(JSON.parse(page));
return {data: JSON.parse(data[1]), total: data[0]};
//return JSON.parse(page);
}
$(document).ready(function () {
var windowTemplate = kendo.template($("#windowTemplate").html());
var window = $("#window").kendoWindow({
title: "Are you sure you want to delete this record?",
visible: false, //the window will not appear before its .open method is called
modal: true,
resizable: false,
draggable: false,
width: "400px",
height: "200px",
}).data("kendoWindow");
var grid = $("#grid").kendoGrid({
dataSource: {
serverPaging: true,
serverFiltering: true,
serverSorting: true,
batch: true,
pageSize: 3,
schema: {
data: "data",
total: function(e){
//alert(e.toSource());
return e.total;
},
model: { id: "id_turma" },
fields: {
id_turma: { editable: false, nullable: true },
nome_turma: { validation: { required: true } },
sigla_turma: { validation: { required: true, max:12 },
data_criacao: { editable: true,type:"date", format: 'dd/MM/yyyy' }}
}
},
transport: {
read: function (option) {
$.ajax({
url: '<?=$view->encode('ctrl.php?turma=lista_turma');?>',
type: "POST",
data:
{
skip: option.data.skip,
take: option.data.take,
pageSize: option.data.pageSize,
page: option.data.page,
sorting: JSON.stringify(option.data.sort),
filter: JSON.stringify(option.data.filter)
},
success: function (result) {
var data = getData(result);
option.success(data);
},
error: function (err) {
alert(err.toSource());
}
});
}
}
},
//sortable: true,
sortable: {
mode: "multiple", // enables multi-column sorting
allowUnsort: true
},
pageable: {
refresh: true,
pageSizes: [5, 10, 20, 50, 100],
buttonCount: 2
},
selectable: true,
filterable: true,
columnMenu: true,
height: 350,
groupable: true,
toolbar: [{name:"create",text:"Adicionar"}],
columns: [
{ field:"nome_turma", title: "Nome"/*, filterable: false*/ },
{ field: "sigla_turma", title:"Sigla", width: "100px" },
{
field: "data_criacao",
title: "Date create",
type: "date",
format: '{0:dd/MM/yyyy}',
template: "#= kendo.toString(kendo.parseDate(data_criacao, 'yyyy-MM-dd'), 'dd/MM/yyyy') #",
filterable: {
ui: "datepicker",
format: '{0:dd/MM/yyyy}'
}
},
{
command:[
{
name: "edit",
text: {
edit: "Editar", // This is the localization for Edit button
update: "Salvar", // This is the localization for Update button
cancel: "Cancelar" // This is the localization for Cancel button
}
},
{
//className: "btn-apagar",
name: "destroy",
text: "Apagar",
click: function(e) {
alert('sdadsdsadsadsa');
var tr = $(e.target).closest("tr"); //get the row for deletion
var data = this.dataItem(tr); //get the row data so it can be referred later
window.content(windowTemplate(data)); //send the row data object to the template and render it
window.open().center();
$("#yesButton").click(function(){
grid.dataSource.remove(data) //prepare a "destroy" request
grid.dataSource.sync() //actually send the request (might be ommited if the autoSync option is enabled in the dataSource)
window.close();
})
$("#noButton").click(function(){
window.close();
})
}
}
]}
//{ command: { text: "ManageEvent", click: showDetails }, title: " Edit Event", width: "60px" },
],
editable : {
mode : "popup",
update: true,
destroy: false,
template: $("#popup_editor").html(),
window : {
title: "Edit Office", // Localization for Edit in the popup window
}
}
});
});
</script>