It works:
$(function() {
$("#dropdownlist").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: "Todos", value: 0 },
{ text: "Valor 1", value: 1 },
{ text: "Valor 2", value: 2 }
]
});
var valor = $("#dropdownlist").data("kendoDropDownList");
function loadGrid(){
$("#grid").kendoGrid({
dataSource:{
transport:{
read: {url:"http://localhost/php/lerdados.php", dataType:"json", data:{"Ordem": valor.value()}, type: "post"}
},
schema:{
type: "json",
data: "xData"
}
},
columns: [
{ field: "Ordem", title: "Ordem"},
{ field: "Data", title: "Data", width: "100px" },
{ field: "Total", title: "Total", format: "{0:c}", width: "100px" }
],
})};
$("#getValue").click(function() {
loadGrid();
});
});
when i declare datasource as variable doesn't work.
$(function() {
$("#dropdownlist").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: "Todos", value: 0 },
{ text: "Valor 1", value: 1 },
{ text: "Valor 2", value: 2 }
]
});
var valor = $("#dropdownlist").data("kendoDropDownList");
var mdataSource = new kendo.data.DataSource({
transport:{
read: {url:"http://localhost/php/lerdados.php", dataType:"json", data:{"Ordem": valor.value()}, type: "post"}
},
schema:{
type: "json",
data: "xData"
}
});
function loadGrid(){
$("#grid").kendoGrid({
dataSource: mdataSource,
columns: [
{ field: "Ordem", title: "Ordem"},
{ field: "Data", title: "Data", width: "100px" },
{ field: "Total", title: "Total", format: "{0:c}", width: "100px" }
],
})
};
$("#getValue").click(function() {
loadGrid();
});
});