I have the following formula in a Combo Box:
var keyObj = getComponent('ACConditionToggle');
var key = keyObj.getSubmittedValue();
if (!key || key==''){
key = keyObj.getValue();
}
switch(key)
{
case 'Approval':
return ['% Approval' , 'Approvers']
break;
case 'Denial':
return ['% Denial', 'Deniers']
default:
return new Array();
}
It works fine, however, I want to have labels different from the value. SO in this case with the label '% Approval' I want a value of 'Percent' and for for 'Approvers' the value of 'Number'
So how do I pass the label and the value from a formula. I can do that with static and get itemLabel and itemValue but how do I differential them in the formula?
after beating my head against the wall I found the answer to be so simple.
var keyObj = getComponent('ACConditionToggle');
var key = keyObj.getSubmittedValue();
var rtnArray = new Array();
if (!key || key==''){
key = keyObj.getValue();
}
switch(key)
{
case 'Approval':
rtnArray[0]="% Approval|Percent";
rtnArray[1]="Approver(s)|Number";
return rtnArray;
break;
case 'Denial':
rtnArray[0]="% Denial|Percent";
rtnArray[1]="Denials(s)|Number";
return rtnArray;
break
default:
return new Array();
}
Related
I'm trying to navigate the rows of an ag-grid table on a react app. This means when I press up or down, the current selected row changes to the previous/next row.
I've tried the example on the ag-grid docs. But I don't know how to access the gridOptions.
How would I make this work?
I think I found a way, although I'm using useRef and I'd prefer to avoid it.
This is the main function:
const arrowKeysNavigation = (tableRef) => (params) => {
var previousCell = params.previousCellPosition;
var suggestedNextCell = params.nextCellPosition;
const api = tableRef.current.api;
var KEY_UP = 38;
var KEY_DOWN = 40;
var KEY_LEFT = 37;
var KEY_RIGHT = 39;
switch (params.key) {
case KEY_DOWN:
previousCell = params.previousCellPosition;
// set selected cell on current cell + 1
api.forEachNode(function (node) {
if (previousCell.rowIndex + 1 === node.rowIndex) {
node.setSelected(true);
}
});
return suggestedNextCell;
case KEY_UP:
previousCell = params.previousCellPosition;
// set selected cell on current cell - 1
api.forEachNode(function (node) {
if (previousCell.rowIndex - 1 === node.rowIndex) {
node.setSelected(true);
}
});
return suggestedNextCell;
case KEY_LEFT:
case KEY_RIGHT:
return suggestedNextCell;
default:
throw new Error(
"this will never happen, navigation is always one of the 4 keys above"
);
}
};
The main steps:
Create ref const tableRef = React.useRef();
Associate it to ag-grid together with the function above:
<AgGridReact ... ref={tableRef} navigateToNextCell={arrowKeysNavigation(tableRef)}/>
Angular js Push array not working in switch case it update last added element only
vm.saveModalData = function(title) {
if (!$scope.parentCtrl.docsList[vm.newDocObj.document_category]){
$scope.parentCtrl.docsList[vm.newDocObj.document_category] = [];
}
if(!title){
title = vm.docFileName;
$scope.parentCtrl.docsList[vm.newDocObj.document_category].push(vm.docFileName);
} else {
$scope.parentCtrl.docsList[vm.newDocObj.document_category].push(title);
}
var doc_obj = {};
doc_obj.title = title;
doc_obj.type = appConstants.DOCUMENT_CATEGORY[selectedCategory];
doc_obj.data = vm.newDocObj.document;
switch(selectedCategory) {
case 'PAN':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
$scope.parentCtrl.completeDetails.pan_document = true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+1].enabled=true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+2].enabled=true;
break;
case 'Aadhaar':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
$scope.parentCtrl.completeDetails.aadhar_document = true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+1].enabled=true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+2].enabled=true;
break;
case 'Driving License':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
$scope.parentCtrl.completeDetails.driving_license_document = true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+1].enabled=true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+2].enabled=true;
break;
case 'Passport':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
$scope.parentCtrl.completeDetails.passport_document = true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+1].enabled=true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+2].enabled=true;
break;
case 'Voter Id':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
$scope.parentCtrl.completeDetails.voter_id_document = true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+1].enabled=true;
$scope.parentCtrl.tabsList[$scope.parentCtrl.activeTab+2].enabled=true;
break;
case 'Company IT Returns':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
break;
case 'Company PAN':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
break;
case 'ITR/VAT Returns/ST Returns':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
break;
case 'Other':
$scope.parentCtrl.completeDetails.documents.push(doc_obj);
break;
default:
break;
}
vm.closeModal();
}
How to fix this issue?
I try to add first document it added into array then i added one more document but it remove existing and add as a new.
Declare your array in parent controller and use $emit on $on for passing data between child to parent controller. Try like below.
function docLpController($scope, $q, appConstants, $uibModal, utils) {
var vm = this;
$scope.parentCtrl = $scope.$parent.finwizzCtrl;
$scope.parentCtrl.completeDetails.documents = []; // declared
$scope.$on('sendData', function (event, data) {
$scope.parentCtrl.completeDetails.documents.push(data);
});
vm.saveModalData = function(title){
$scope.$emit('sendData', doc_obj);
}
Try this,
You are calling docCtrl.openAddDocModal(doc) function, while adding each and every time of Document add. Inside that function only you have initialised your array.
$scope.parentCtrl.completeDetails.documents = [];
so that each and every time it's getting reinitialised with empty.
Add this code line out side of the $uibModal.open(), recommended add below $scope.arr = [];
hope it will work...
im using ag-Grid, but there is a issue when it filters my data, when i filter my data in the price column, it only works with numbers dot and not with commas.
Link: https://plnkr.co/edit/LDdrRbANSalvb4Iwh5mp?p=preview
Practical Example:
In the Price column select box equal and above insert "1.5" and than try inserting "1,5"
This is because this filter is a native one.
If you want to handle custom behaviour, define your own filter.
Documentation : https://www.ag-grid.com/angular-grid-filtering/index.php
A quick and dirty solution would be to monkey patch the NumberFilter like this :
NumberFilter.prototype.doesFilterPass = function (node) {
if (this.filterNumber === null) {
return true;
}
var value = this.valueGetter(node);
if (!value && value !== 0) {
return false;
}
var valueAsNumber;
if (typeof value === 'number') {
valueAsNumber = value;
}
else {
valueAsNumber = parseFloat(value.replace(',','.'));
}
switch (this.filterType) {
case EQUALS:
return valueAsNumber === this.filterNumber;
case LESS_THAN:
return valueAsNumber < this.filterNumber;
case GREATER_THAN:
return valueAsNumber > this.filterNumber;
default:
// should never happen
console.warn('invalid filter type ' + this.filterType);
return false;
}
};
Then changed line is here :
valueAsNumber = parseFloat(value.replace(',','.'));
So i found the problem, first i had to convert the value has a string than i needed to replace the dot by the comma, the problem with the answer above was first because of the data type and than the order of the properties of the replace function, but the problem now is that is not filtering correctly, if i search using equal option if gives me 2 values, instead a fixed one, code looks something like this:
Code:
NumberFilter.prototype.doesFilterPass = function (node) {
if (this.filterNumber === null) {
return true;
}
var value = this.valueGetter(node);
if (!value && value !== 0) {
return false;
}
var valueAsNumber;
if (typeof value === 'number') {
value = value.toString()
valueAsNumber = parseFloat(value.replace('.',','));
}
else {
valueAsNumber = parseFloat(value.replace('.',','));
}
switch (this.filterType) {
case EQUALS:
return valueAsNumber === this.filterNumber;
case LESS_THAN:
return valueAsNumber < this.filterNumber;
case GREATER_THAN:
return valueAsNumber > this.filterNumber;
default:
// should never happen
console.warn('invalid filter type ' + this.filterType);
return false;
}
};
Possible Solution:
NumberFilter.prototype.onFilterChanged = function () {
var filterText = utils_1.default.makeNull(this.eFilterTextField.value);
if (filterText && filterText.trim() === '') {
filterText = null;
}
var newFilter;
if (filterText !== null && filterText !== undefined) {
console.log(filterText);
// replace comma by dot
newFilter = parseFloat(filterText.replace(/,/g, '.'));
console.log(newFilter);
}
else {
newFilter = null;
}
if (this.filterNumber !== newFilter) {
this.filterNumber = newFilter;
this.filterChanged();
}
};
I want to show one more currencies in a page. For example
$100,000 And 100,000€
When I use $filter('currency')(100000, '€') it returns €100,000. But I want it as 100,000€
The problem is I cannot replace the symbol. Any idea ?
You can always create a custom filter.
app.filter('customCurrency',['$filter', function(filter) {
var currencyFilter = filter('currency');
return function(amount, currencySymbol) {
var value = currencyFilter(amount).substring(1);
var currency = "";
switch(currencySymbol) {
case '$':
currency = currencySymbol + value;
break;
case '€':
currency = value + currencySymbol;
break;
}
return currency;
}}])
Here is the working example:
http://plnkr.co/edit/IIWG18?p=preview
I have an object which is assigned a number of properties:
var project_array:Array = [];
var slideObject:Object = {
project_title : myXML.projects.project[i].title.toUpperCase(),
project_desc : myXML.projects.project[i].description.toUpperCase(),
project_name : myXML.projects.project[i].name.toUpperCase(),
project_agency : myXML.projects.project[i].agency.toUpperCase(),
project_img : myXML.projects.project[i].#img,
project_types : myXML.projects.project[i].#type.split(", ")
}
project_array.push(slideObject);
What I want to be able to do is, based on the values within slideObject.project_types, create another array within slideObject that keeps track of project_clips - like this:
for ( var i in project_types_array) {
/*(var typeClass:Class = getDefinitionByName('type_' + project_types_array[i]);
(var typeClip:typeClass = new typeClass();
project_clips_array.push(typeClip);
trace (project_types_array[i]);*/
switch (project_types_array[i]){
case "p":
var clip_p = new type_p();
project_clips_array.push(clip_p);
break;
case "exp":
var clip_exp = new type_exp();
project_clips_array.push(clip_exp);
break;
case "f":
var clip_f = new type_f();
project_clips_array.push(clip_f);
break;
case "oi":
var clip_oi = new type_oi();
project_clips_array.push(clip_oi);
break;
case "tv":
var clip_tv = new type_tv();
project_clips_array.push(clip_tv);
break;
}
}
but I'm not quite sure where to place this. If I place it outside of the object constructor, I get "term is undefined", I guess because it doesn't know what project_clips_array is - but if I declare project_clips_array in the constructor, it appears to need to be defined, i.e. I can't create a blank property. But I can't place it in the constructor either, because it doesn't seem to allow me to run a function within an object constructor. What is the proper syntax or arrangement of code for executing this function to get the array within the object?
I think something like this should work:
var project_array:Array = [];
var slideObject:Object = {
project_title : myXML.projects.project[i].title.toUpperCase(),
project_desc : myXML.projects.project[i].description.toUpperCase(),
project_name : myXML.projects.project[i].name.toUpperCase(),
project_agency : myXML.projects.project[i].agency.toUpperCase(),
project_img : myXML.projects.project[i].#img,
project_types : myXML.projects.project[i].#type.split(", ")
}
slideObject.project_type_array = sortTypes(slideObject.project_types);
project_array.push(slideObject);
function sortTypes(orig_array:Array):Array
{
var type_array:Array = [];
for ( var i in orig_array)
{
switch (orig_array[i])
{
case "p":
var clip_p = new type_p();
type_array.push(clip_p);
break;
case "exp":
var clip_exp = new type_exp();
type_array.push(clip_exp);
break;
case "f":
var clip_f = new type_f();
type_array.push(clip_f);
break;
case "oi":
var clip_oi = new type_oi();
new_array.push(clip_oi);
break;
case "tv":
var clip_tv = new type_tv();
type_array.push(clip_tv);
break;
}
}
return type_array;
}
I set it up like this:
for (var i=0;i<tp;i++){
var slideObject:Object = {
project_title : myXML.projects.project[i].title.toUpperCase(),
project_desc : myXML.projects.project[i].description.toUpperCase(),
project_name : myXML.projects.project[i].name.toUpperCase(),
project_agency : myXML.projects.project[i].agency.toUpperCase(),
project_img : myXML.projects.project[i].#img,
project_types : myXML.projects.project[i].#type.split(", "),
project_type_clips : [],
}
for (var j in slideObject.project_types){
//trace ("object" + i + " | type " + j)
switch (slideObject.project_types[j]){
case "p":
var clip_p = new type_p();
slideObject.project_type_clips.push(clip_p);
break;
case "exp":
var clip_exp = new type_exp();
slideObject.project_type_clips.push(clip_exp);
break;
case "f":
var clip_f = new type_f();
slideObject.project_type_clips.push(clip_f);
break;
case "oi":
var clip_oi = new type_oi();
slideObject.project_type_clips.push(clip_oi);
break;
case "tv":
var clip_tv = new type_tv();
slideObject.project_type_clips.push(clip_tv);
break;
}
} //end project_types loop
project_array.push(slideObject);
} // end object creation loop
loadProject();
}