Grid Datasource data not refresh when click button

2 posts, 0 answers
  1. Jun
    Jun avatar
    6 posts
    Member since:
    Jul 2012

    Posted 09 Mar Link to this post

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

    });
        });

  2. Preslav
    Admin
    Preslav avatar
    350 posts

    Posted 12 Mar Link to this post

    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.
Back to Top