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

grid.dataSource.read() isn't making a request to refresh the grid data

3 Answers 1512 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 04 Jul 2013, 12:06 AM
I have an upload widget outside the grid asynchronously uploading files. Upon completion I try to refresh the grid displaying details about these files. However, when I call grid.dataSource.read() the grid datasource is not making a request to the remote service to get new data. I already set cache=false in the transport. I even try to call the read() method in the browser (chrome) console and it still doesn't cause a request to the remote service. Can you see what is wrong?

001.$(document).ready(function() {
002.    var $grid = $("#samples-all").kendoGrid({
003.        dataSource: {
004.            transport: {
005.                read: "/uploads/",
006.                dataType: "json",
007.                create: {
008.                  /* don't cache grid items, otherwise miss new uploads */
009.                  cache: false
010.                }
011.            },
012.            schema: {
013.                data: "rows",
014.                total: "totalRows"
015.            },
016.            pageSize: 20,
017.            serverPaging: true,
018.            serverFiltering: true
019.        },
020.        pageable: true,
021.        scrollable: false,
022.        filterable: {
023.            extra: false,
024.            operators: {
025.                string: {
026.                    eq: "Is equal to",
027.                    neq: "Is not equal to"
028.                }
029.            }
030.        },
031.        columns: [
032.            {
033.                field: "threat_presence",
034.                title: " ",
035.                template: kendo.template($("#tp-template").html(), { useWithBlock: false }),
036.                width: 29,
037.                filterable: {
038.                    ui: threatFilter
039.                }
040.            },
041.            {
042.                field: "file_name",
043.                title: "Name",
044.                template: kendo.template($("#file-name-template").html(), { useWithBlock: false }),
045.                width: 250,
046.                filterable: false
047.            },
048.            {
049.                field: "file_type",
050.                title: "Type",
051.                filterable: false
052.            },
053.            {
054.                field: "file_count",
055.                title: "File Count",
056.                width: 55,
057.                filterable: false
058.            },
059.            {
060.                field: "sha1",
061.                title: "SHA1",
062.                width: 250,
063.                filterable: false
064.            },
065.            {
066.                field: "message",
067.                title: "Status",
068.                width: 70,
069.                filterable: false
070.            },
071.            {
072.                field: "inserted",
073.                title: "First Seen",
074.                filterable: false
075.            },
076.            { command: { text: "Download", click: download }, title: " ", width: "85px" }
077.        ]
078.    }).data("kendoGrid");
079.    // setup the upload window and toolbar button
080.    var $uploadWindow = $("#uploadWindow"),
081.        $btnUpload = $("#btnUpload").on("click", function() {
082.            $uploadWindow.data("kendoWindow").open();
083.        });
084. 
085.    if (!$uploadWindow.data("kendoWindow")) {
086.        $uploadWindow.kendoWindow({
087.            width: "400px",
088.            title: "Upload",
089.            visible: false
090.        });
091.    }
092.    $("#upload-file").kendoUpload({
093.        async: {
094.            saveUrl: "/upload-samples/",
095.            removeUrl: "remove",
096.            autoUpload: false
097.        },
098.        upload: onUpload,
099.        success: onUploadSuccess,
100.        complete: onUploadComplete
101.    });
102.     
103.    function onUpload(e) {
104.        // omitted
105.    }
106.    function onUploadSuccess(e) {
107.        // omitted
108.    }
109.    function onUploadComplete(e) {
110.        console.log(e);
111.        var grid = $("#samples-all").data("kendoGrid");
112.        grid.dataSource.read();
113.        grid.refresh();
114.    }
115.});
html:
<div id="samples-list-container">
    <div id="samples-all"></div>
</div>

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 05 Jul 2013, 09:01 AM
Hi Joshua,

The cache: false is set on the create, not read transport. Please try the following:
transport: {
    read: {
        url: "/uploads/",
        dataType: "json",
        /* don't cache grid items, otherwise miss new uploads */
        cache: false
    }
},

I hope this will help.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Balu
Top achievements
Rank 1
answered on 29 Nov 2013, 05:50 AM
Since there is a cache issue, How  can I set below code with Asp.net MVC wrapper?
 transport: {
read: {
cache: false
}
}
0
Alexander Valchev
Telerik team
answered on 02 Dec 2013, 12:50 PM
Hi Balu,

I am afraid that you cannot customize the Ajax request settings through the MVC wrappers. As a possible workaround I suggest you to use jQuery.ajaxSetup.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Balu
Top achievements
Rank 1
Share this question
or