zoukankan      html  css  js  c++  java
  • 给Grid动态添加列和添加样式

    BudgetProjectSearch: function () {
    $("#load").show();
    var that = this;
    var postmodel = {};
    postmodel.year = that.YearStr;
    postmodel.month = that.monthvalue;
    //获取所有选中的节点
    var nodes = $("#tree").data("kendoTreeView").dataSource.view();
    var checkedNodes = [];
    checkedNodeIds(nodes, checkedNodes);
    postmodel.OrgData = checkedNodes;
    postmodel.selectedExpenseItemIdStr = that.selectedExpenseItemIdStr;
    if (postmodel.OrgData.length == 0) {
    $("#load").hide();
    messageBox.show({ message: "请选择部门" }, "info");
    }
    else if (postmodel.selectedExpenseItemIdStr.length == 0) {
    $("#load").hide();
    messageBox.show({ message: "请选择费用项目" }, "info");
    }
    else if (postmodel.year == null || postmodel.year == "") {
    $("#load").hide();
    messageBox.show({ message: "请选择年份" }, "info");
    }
    else if (postmodel.month == null || postmodel.month == "") {
    $("#load").hide();
    messageBox.show({ message: "请选择月份" }, "info");
    }
    else {
    $.post("/Reports/CompanyReport/GetBudgetActualAchievementList", postmodel, function (r) {
    $("#load").hide();
    if (r.status == 202) {
    messageBox.show({ message: r.msg }, "info");
    }
    else {
    //根据费用项目初始化filed
    var columns = [];
    columns.push({
    field: "EmployeeName",
    title: "名称",
    400
    });
    columns.push({
    field: "AllTotolBuget",
    title: "全年合计预算",
    attributes: { class: 'center' },
    150
    });
    for (var i = 1; i <= postmodel.month; i++) {
    if (i == 1) {
    columns.push({
    field: "Actual01",
    title: "1月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 2) {
    columns.push({
    field: "Actual02",
    title: "2月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 3) {
    columns.push({
    field: "Actual03",
    title: "3月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 4) {
    columns.push({
    field: "Actual04",
    title: "4月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 5) {
    columns.push({
    field: "Actual05",
    title: "5月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 6) {
    columns.push({
    field: "Actual06",
    title: "6月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 7) {
    columns.push({
    field: "Actual07",
    title: "7月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 8) {
    columns.push({
    field: "Actual08",
    title: "8月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 9) {
    columns.push({
    field: "Actual09",
    title: "9月",
    attributes: { class: 'center' },
    100
    });
    } if (i == 10) {
    columns.push({
    field: "Actual10",
    title: "10月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 11) {
    columns.push({
    field: "Actual11",
    title: "11月",
    attributes: { class: 'center' },
    100
    });
    }
    if (i == 12) {
    columns.push({
    field: "Actual12",
    title: "12月",
    attributes: { class: 'center' },
    100
    });
    }

    }
    columns.push({
    field: "ActualTotol",
    title: "报销合计",
    attributes: { class: 'center' },
    100
    });
    columns.push({
    field: "BugetTotol",
    title: "实际发生月预算合计",
    attributes: { class: 'center' },
    200
    });
    columns.push({
    field: "difference",
    title: "差异",
    attributes: { class: 'center' },
    100
    });
    columns.push({
    field: "AllSurplusBuget",
    title: "全年剩余预算",
    attributes: { class: 'center' },
    150
    });
    var grid = $("#grid").data("kendoGrid");
    grid.setOptions({
    columns: columns
    });
    var dataSource = new kendo.data.DataSource({
    data: JSON.parse(r.data),
    //pageSize: 15,
    });
    grid.setDataSource(dataSource);
    grid.dataSource.page(1);

    debugger
    if (grid.dataSource != null) {
    if (grid.dataSource.data().length > 0) {
    _.each(grid.dataSource.data(), function (data) {
    if (data.IsOrgTotol == "1") {
    $("[data-uid='" + data.uid + "']").css("background-color", "#FFC0CB");
    }
    if (data.IsOrgTotol == "2") {
    $("[data-uid='" + data.uid + "']").css("background-color", "#F58220");
    }
    })
    }
    }
    }
    });
    }
    },

  • 相关阅读:
    Kubernetes实战模拟三(wordpress健康检查和服务质量QoS)
    Kubernetes实战模拟二(wordpress高可用)
    Kubernetes实战模拟一(wordpress基础版)
    Rook部署测试Ceph和wordpress实战应用
    kettle作业转换的执行
    BUU BURP COURSE 1
    BUU SQL COURSE 1
    BUU CODE REVIEW 1
    查看FGC
    Pod大量为Evicted被驱逐状态
  • 原文地址:https://www.cnblogs.com/jiangcm/p/7767261.html
Copyright © 2011-2022 走看看