gpt4 book ai didi

angularjs - 如何有条件地将样式应用于 Kendo UI 网格 'row' ?

转载 作者:行者123 更新时间:2023-12-04 12:19:52 27 4
gpt4 key购买 nike

我的 Angular 页面有以下 Kendo UI gridOptions:

ctrl.gridOptions = {
rowTemplate: '<tr data-uid="#: uid #" class="#:ApprovalStatus=\'Approved\'? \"approved\" : \"unapporved\"#"></tr>',
//rowTemplate: '<tr data-uid="#: uid #" class="#:ApprovalStatus=\'Approved\' ? \'approved\' : \'unapproved\' #"><td>#:ProcessName #</td><td>#:TradeAmount #</td><td>#:AQRID #</td><td>#:ApprovalStatus #</td></tr>',
dataSource: {
type: 'json',
transport: {
read: function (options) {
DataSvc.getTradesData().then(function (response) {
options.success(response.data);

}, function (response) {
alert('something went wrong')
console.log(status);
});
}
},
schema: {
model: {
fields: {
IsChecked: { type: "boolean" },
ProcessName: { type: "string" },
TradeAmount: { type: "number" },
ApprovalStatus: { type: "string" }
}
}
},
},
selectable: "row",
sortable: true,
columns: [
{ field: "IsChecked", width: "30px", title: " ", template: '<input ng-disabled="dataItem.ApprovalStatus" ng-model="dataItem.IsChecked" type="checkbox" />', filterable: false, headerTemplate: '<input type="checkbox" ng-click="ctrl.checkAllTrades()" ng-model="ctrl.tradesChecked">' },
{ field: "ProcessName", title: "Process Name", width: "190px", filterable: { cell: { showOperators: false, template: processNameDropDownEditor } }, template: '<a style="font-size: x-normal;" href="#=Link#">{{dataItem.ProcessName}}</a>', attributes: { style: "text-align:left;" } },
{ field: "TradeAmount", title: "Trade Amount", width: "120px", filterable: { cell: { showOperators: false } } },
{ field: "ApprovalStatus", title: "Approval Status", width: "150px", filterable: { cell: { showOperators: false, template: approvalStatusDropDownEditor } } }
],
filterable: { mode: "row" },
height: 550,
};

批准和未批准的样式定义如下:
.approved {
background-color: green;
}

.unapproved{
background-color: red;
}

所以问题是当我应用行模板时,网格呈现为空。当我应用注释的 rowTemplate 时,网格会与行一起呈现,但仅应用“已批准”样式,如下所示:

enter image description here

如何根据数据绑定(bind)字段的条件将样式应用于每个 TR?此外,当应用注释的 rowTemplate 时,列未正确显示,我们该如何解决?

更新:

下面的 rowTemplate 帮助修复了背景颜色问题。但仍然无法解决列对齐问题。
rowTemplate: '<tr data-uid="#: uid #" ng-class="{approved: \'#:ApprovalStatus#\' ==\'Approved\', unapproved: \'#:ApprovalStatus#\' ==\'Unapproved\'}"><td>#:ProcessName #</td><td>#:Account #</td><td>#:AQRID #</td><td>#:ApprovalStatus #</td></tr>',

最佳答案

您可以查看 fiddle ,
希望它有帮助....

关于angularjs - 如何有条件地将样式应用于 Kendo UI 网格 'row' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30672067/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com