Grid with template column not allowing dataSource.read()

3 posts, 0 answers
  1. Lee
    Lee avatar
    2 posts
    Member since:
    Sep 2014

    Posted 15 Apr 2016 Link to this post

    I have the following set up:

        var documentListDataSource = new kendo.data.DataSource({
            transport: {
                read: function (options) {
                    debugger;
                    var fnum = editData != null ? editData.Number : '';
                    var vrid = editData != null ? editData.FormVersionId : 0;
                    $.ajax({
                        url: '@Url.Action("GetFormDocumentList", "Form")',
                        dataType: "json",
                        async: false,
                        type: "POST",
                        data: { formNumber: fnum, formVersionId: vrid },
                        success: function (data) {
                            options.success(data);
                        }
                    });
                }
            }
        });

     

        function initDocumentGrid() {
            $("#DocumentGrid").kendoGrid({
                dataSource: documentListDataSource,
                navigatable: true,
                selectable: "row",
                columns: [{
                    field: "Format",
                    title: "Format",
                    width: 150
                }, {
                    field: "Name",
                    title: "File Name",
                    width: 150
                }, {
                    title: "Actions",
                    template: function (dataItem) {
                        return BuildDocumentActionButtons(dataItem);
                    }
                }]

            });
        }

        function BuildDocumentActionButtons(dataItem) {
            var retval = '';


            if (dataItem.Extension == "xpd") {
                // interactive mapping button
                //retval += "<button class='k-button k-button-icontext' onclick='OpenMappingWindow();'>Conversion Map</button>"
            }
            if (retval.length > 0) retval += ' &nbsp; ';
            // upload document button - always rendered
            retval += "<button class='k-button k-button-icontext' onclick='OpenUploadWindow(" + datItem.Extension + ");'>Upload</button>"
            //if (dataItem.Name != "") {
            //    retval += ' &nbsp; ';
            //    // toggle availability button
            //    retval += "<button class='k-button k-button-icontext' onclick='ToggleAvailability(" + datItem.Name + ");'>Availability</button>"
            //    retval += ' &nbsp; ';
            //    // remove document button
            //    retval += "<button class='k-button k-button-icontext' onclick='RemoveDocument(" + datItem.Name + ");'>Remove</button>"
            //}
            return retval;
        }


    When retval returns button definitions, the following call fails with no error:

    $("#DocumentGrid").data("kendoGrid").dataSource.read();

     

    I am doing something wrong, but am missing it.

     

    Any assistance would be most appreciated.

     

  2. Lee
    Lee avatar
    2 posts
    Member since:
    Sep 2014

    Posted 19 Apr 2016 Link to this post

    Never mind.  Invalid javascript will fail with no error thrown.  Semicolons and proper spelling are fundamental.  ><
  3. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 19 Apr 2016 Link to this post

    Hello Lee,

    Thanks for the update. I am glad the issue is resolved.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top