Metric Name | Aggregation Type | Weighting Field |
Metric_1 | Average | |
Metric_2 | Average | |
Metric_3 | Weighted Average | Metric_2 |
var onchange = function (args) { if (isAggTypeWeightedAverage(args)) { $("#GridweightingField").ejDropDownList("enable"); var index; $.each(weightingFieldMetrics, function (key, value) { if (value["text"] == "Metric_2") index = key; }); if (index != null) { weightingFieldMetrics.splice(index, 1);
$("#GridweightingField").ejDropDownList("option", "dataSource", weightingFieldMetrics); }
} else { $("#GridweightingField").ejDropDownList("disable"); } |
$scope.tools = ["add", "edit", "delete", "update", "cancel"]; $scope.columns = [ { field: "ordinal", isPrimaryKey: true, type: "number" }, { field: "metricfieldname", headerText: "Metric Name", editType: ej.Grid.EditingType.String, width: 100 }, { field: "aggregationType", headerText: "Aggregation Type", editType: ej.Grid.EditingType.Dropdown, dataSource: aggTypes, foreignKeyField: "value", foreignKeyValue: "text", width: 75 }, { field: "weightingField", headerText: "Weighting Field", editType: ej.Grid.EditingType.Dropdown, dataSource: weightingFieldMetrics, foreignKeyField: "value", foreignKeyValue: "text", width: 75 } |
if (args.requestType == "save") { if(isAggregationTypeField(args.data.aggregationType)) { var newMetric = { "text": args.data.metricfieldname, "value": args.data.ordinal }; weightingFieldMetrics.push(newMetric);
} var gridObj = $("#Grid").data("ejGrid"); gridObj.columns(gridObj.model.columns[3], "update"); |