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

JSON, html template and grid with pop up window error

0 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gy
Top achievements
Rank 1
Gy asked on 28 Jan 2012, 05:57 AM
Hi,

I got a grid which loading JSON data from a php file.
Inside this data, I got some html code to update grid template (some calls for ajax window).

One of my try:
$("#grid").kendoGrid({
        dataSource: {
            transport: {
                dataType: "jsonp",
                read: {
                    url: "http://localhost/cmms/service/request.php?user=iitpd&act=overdue"
                }
            },
            schema: {
                model: {
                    NUM: "NUM",
                    fields: {
                        NOM: {
                            editable: false,
                            nullable: true
                        },
                        DEP: {
                            editable: false,
                            nullable: true
                        },
                        DEP: {
                            editable: false,
                            nullable: true
                        },
                        DUE: {
                            editable: false,
                            nullable: true,
                            type: "date"
                        },
                        START: {
                            //defaultValue: 42,
                            type: "date"
                        },
                        COMP: {}
                            }
                        }
                    },
            pageSize: 15,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        },
        height: 360,
        toolbar: ["save", "cancel"],
        editable: true,
        groupable: true,
        scrollable: true,
        sortable: true,
        pageable: true,
        selectable: "row",
        columns: [
            {field: "NUM", width: 20, title: "Code" },
            {field: "NOM", width: 150, title: "Name" },
            {field: "DEP",width: 40,title: "Department"},
            {width: 30,title: "Description", template:"#=DESC#"},
            {field: "DUE",width: 30,title: "Due date"},
            {width: 50,title: "Started", template:"#=START#"},
            {width: 30,title: "Completed",template:'<div id="comp=#=NUM#" class="pop">Select</div>'}]
    });

and another one:
$("#grid").kendoGrid({
        dataSource: data,
        height: 360,
        toolbar: ["save", "cancel"],
        editable: true,
        groupable: true,
        scrollable: true,
        sortable: true,
        pageable: true,
        selectable: "row",
        columns: [
            {field: "NUM", width: 20, title: "Code" },
            {field: "NOM", width: 150, title: "Name" },
            {field: "DEP",width: 40,title: "Department"},
            {width: 30,title: "Description", template:"#=DESC#"},
            {field: "DUE",width: 30,title: "Due date"},
            {width: 50,title: "Started", template:"#=START#"},
            {width: 30,title: "Completed",template:'<div id="comp=#=NUM#" class="pop">Select</div>'}]
    });

After the grid, i have this code, to open the windows:
var window = $("#window");
    var windesc = $("#windesc");
 
    $("#grid").click(function(){
        $(".pop").click(function(){
            var caseid = $(this).attr("id");
            window.data("kendoWindow").refresh('date.php?'+caseid);
            window.data("kendoWindow").center();
            window.data("kendoWindow").open();
        });
    });
     
     
    $(".desc").click(function(){
        var caseid = $(this).attr("id");
        var caseti = $(this).attr("ti");
        windesc.data("kendoWindow").title(caseti);
        windesc.data("kendoWindow").refresh('desc.php?'+caseid);
        windesc.data("kendoWindow").center();
        windesc.data("kendoWindow").open();
    });

In the variable #=DESC# & #=START#, the script load well a '<div id="test" class="pop">SELECT</div>' in dataSource but the html is not read and it appears as string in the cell if i use "field".

If i use the schema way, I got a "q is undefined" error.
If i use a template in columns, in firebug, i got an error "this is undefined" when i click on the cell..... If i load some local data with createData exemple function, the html is read and despite the "this" error is still there, the window open..... Cannot find how to solve that.



No answers yet. Maybe you can help?

Tags
Grid
Asked by
Gy
Top achievements
Rank 1
Share this question
or