绑定kendogrid,使用大型数据源(json数组),需要任何动态

时间:2013-07-19 08:02:15

标签: javascript grid kendo-ui bind

我想绑定一个带有大数据源(json数组)的kendogrid,其中包括3-4个选项卡中的细节temeplates的显示。但它不显示网格。 (1500行)是否有任何动态可以逐页显示?解决方案无需搜索条件。

请告知。

感谢Yogesh

1 个答案:

答案 0 :(得分:0)

 function bindgridsimple() 
 {
    var element = $("#grid").kendoGrid({
    dataSource: {
    transport: {
    read: url
    },
    pageSize: 25
    },
    columnMenu: true,
    scrollable: true,
    filterable: true,
    resizable: true,
    sortable: true,
    detailTemplate: kendo.template($("#template").html()),
    detailInit: detailInit,
    dataBound: function () {                
    },
    columns: [
    {
    field: "FirstName",
    width: "8%",
    title: "Candidate Name",
    template: "<a  href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#'> <span>#=FirstName#</span>&nbsp;<span>#=LastName#</span></a>" 
    },
    {
    field: "Mobile",
    width: "8%",
    title: "Mobile"
    },
    {
    field: "ResumeTitle",
    width: "10%",
    title: "Resume Title"
    },
    {
    field: "CreatedByUser",
    width: "10%",
    title: "Created by"
    },
    {
    field: "ExpectedSalary",
    width: "15%",
    title: "Expected Salary",
    template: "<span># if(ExpectedSalary == null) { # 0.00 # } else { #<span>#=ExpectedSalary#</span># }#</span>&nbsp;/&nbsp;<span>#=ExpectedSalaryperiod#</span>"
    },                    {
    field: "MarketingRate",
    width: "10%",
    title: "Mktg Rate",
    template: "<span># if(MarketingRate == null) { # 0.00 # } else { #<span>#=MarketingRate#</span># }#</span>&nbsp;/&nbsp;<span>#=MarketingRateperiod#</span>"
    },
    {
    field: "CreatedDate",
    width: "15%",
    title: "Resume Received Date",
    template: '#if(Resume == null || Resume == "") {  } else { # <span> #=parseFullDate(CreatedDate)# </span>  # } #'
    },
    {
    field: "ExistMappedCandidate",
    width: "10%",
    title: "Req. Provided"
    },
    {    
    field: "ExistMappedCandidate",
    width: "10%",
    title: "View",
    template: "# if(ExistMappedCandidate==true){ #<a href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#'>View Requirement</a> #} else {# <a href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#' class='No-candidates' onclick='return false' title='No requirements are mapped with this candidate.'>View Requirement</a> #}#"
    }
    ],
    pageable: {
    pageSizes: [25, 50, 75]
    }
    });
    }

   function detailInit(e) {
     var sharableDataSource = new kendo.data.DataSource({ data: e.data.Experience });
     var sharableDataSourceAttachment = new kendo.data.DataSource({ data: e.data.Attachments });

     var detailRow = e.detailRow;
     detailRow.find(".tabstrip").kendoTabStrip({
     animation: {
     open: { effects: "fadeIn" }
     }
     });

     detailRow.find(".prevExperience").kendoGrid({
            dataSource: { data: e.data.Experience,
                pageSize: 10
            },
            columnMenu: true,
            scrollable: true,
            filterable: true,
            resizable: false,
            sortable: true,
            pageable: {
                pageSizes: [10, 20]
            },
            columns: [
                        { field: "Company", title: "Company Name", width: "100px" },
                        { field: "Designation", title: "Designation", width: "100px" },
                        { field: "FromDate", title: "From", width: "100px", template: '#=parsemyDate(FromDate)#' },
                        { field: "ToDate", title: "To", width: "100px", template: '#=parsemyDate(ToDate)#' },
                        { field: "LastSalary", title: "Last CTC", width: "65px", template: '#=LastSalary# / Yr' }
                    ]
        });

        detailRow.find(".attachments").kendoGrid({
            //dataSource: sharableDataSourceAttachment,
            dataSource: { data: e.data.Attachments,
                pageSize: 10
            },
            columnMenu:true,
            scrollable: false,
            sortable: true, 
            filterable: true,        
            pageable: {
                pageSizes: [10, 20]
            },
            columns: [
                        { field: "AttachmentName", sortable: true, filterable: true, title: "File Icon", width: "100px", template: '<a href="Attachments/#=AttachmentName#">#= AttachmentTitle #</a>'
                        },
            //                        { field: "AttachmentTitle", title: "Type", width: "100px" },
            //                        { field: "AttachmentName", title: "Subject", width: "100px", template: 'Resume' },
                        {field: "CreatedbyUser", sortable: true, filterable: true, title: "Attached By", width: "100px" },
                        { field: "Createddate", title: "Date", sortable: true, filterable: true, width: "65px", template: '#=parseFullDate(Createddate)#' }
                    ]
        });
    }