私は、特定のテーブルの内容のセルに追加のクラスやスタイルルールが必要なuiグリッド内にいくつかのユニークなケースがあるため、他の人に。公式のui-gridドキュメントを見てみると、cellTemplateで行うことができますが、一貫した結果は得られませんでした。ここで最善のアプローチは何ですか?uiグリッド内のセルのクラス値またはスタイルを変更する
以下の意図は、フィルタの呼び出しから返された値に基づいて、クラス名を変更することで、私が前に試みられてきたコードの変更は、「関連ドキュメント」から
//Define Grid Headings
$scope.scheduledPatientAppointments = [
{
field: 'appointment_date',
displayName: 'Appointment Date'
},
{
field: 'doctor_name',
displayName: 'Doctor Name'
},
{
field: 'procedure_type_eng',
displayName: 'Medical Procedure Type'
},
{
field: 'appointment_status_eng',
displayName: 'Appointment Status'
},
{
field: 'docs_received',
displayName: 'Related Documents',
cellTemplate: '<div class="ui-grid-cell-contents" ng-click="grid.appScope.loadDocumentsModal(\'{{row.entity.id}}\')">{{grid.getCellValue(row, col) | hasDocuments}}</div>',
cellFilter: 'hasDocuments',
cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
if (grid.getCellValue(row, col).toLowerCase() === 'missing') {
return 'missing';
} else if (grid.getCellValue(row, col).toLowerCase() === 'received') {
return 'received';
} else {
return 'undefined';
}
}
}
];
// Define Grid Options
$scope.PatientAppointmentsGrid = {
selectionRowHeaderWidth: 25,
enableHorizontalScrollbar: false,
rowHeight: 35,
enableSorting: true,
columnDefs: $scope.columnsPatient,
data: [],
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
}
};
//Behavior for patient page load
$scope.appointmentsProvider = patientsService.patientFactory.getAppointmentsForPatient($stateParams.id).then(
function successCallback(response) {
var preFetchData = response.data.data;
angular.forEach(preFetchData, function (value, key) {documentsService.documentsFactory.getDocumentsByAppointmentId(value.id).then(
function successCallback(response2) {
if (response2.data.length >= 1) {
//Append value state to the preFetchData object (count size)
var totalFiles = response2.data.length;
preFetchData[key].docs_received = totalFiles;
} else {
preFetchData[key].docs_received = 0;
}
}, function errorCallback(response2) {
console.debug("Error", response2);
});
});
$scope.PatientAppointmentsGrid.data = preFetchData;
},
function errorCallback(response) {
console.debug("Error", response);
});
内容は作られていますinitallyあります(元の残りの呼び出しは何も返しませんが、フィルター呼び出しによってその呼び出しが設定されますが、後の呼び出しで行ごとに関連する文書が実際にロードされます)、この特定の呼び出しのグリッドの非アクティブは、ここに設定する
ここに最善のアプローチに関する考え方
これまでに試したことのサンプルコードを含めると良いでしょうし、現行のメソッドについて何が矛盾しているのか、それがどのような動作をしているのかを少し詳しく説明してください。 – shaunhusain
もちろん、いくつかのサンプルコードを追加して、私が何を目指しているのか、そしてどのように明確にしましたか。 –