This is a migrated thread and some comments may be shown as answers.

Grid Datasource data not refresh when click button

1 Answer 687 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jun
Top achievements
Rank 1
Jun asked on 09 Mar 2018, 02:28 PM

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();
  

});
    });

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 12 Mar 2018, 11:45 AM
Hello Jun,

Based on the provided code I created a sample page and it seems that the Grid loads as expected on my side.

Having said that, could you please check and modify my test page:
so it clearly replicates the behavior on your side? After that, sand it back with your next reply. This will help me fully understand the case and I will be able to provide assistance to the best of my knowledge.

I look forward to hearing from you.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Jun
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or