How to access hidden column in angular js - angularjs

I have a column named id in my datagrid. I have set visible:false for the field since I don't want to display the field in the grid.
But then how can I get the value in id? any hope?
I am adding column as
columns.push({'sTitle':'id','visible': 'false'},{'sTitle':'name','visible': 'false'});
And I am retrieving the value in selected row as
this.$view.on("click",function(event){
selectedRow = event.target.parentElement;
var name = selectedRow.cells[0].innerHTML;
}
Here in click event I can't get the value of id as html is not generated for the field with visible:false. So I am searching for a method to access my id field.

You should use display:none property
-Edit:
In order to specify a custom css to your angular datagrid you should also specify the columns. Something like:
$("#gridContainer").dxDataGrid({
// ...
columns: ['CompanyName', 'ContactName', 'City', 'Country']
});
Here's the page I referenced to
Edit2:
Since you're trying to retrieve the value of the field I would recommend you to take a look to this answer

Related

Salesforce lightning:treegrid find Id/data of deselected row

I am working with a lightning:treegrid component.
The onrowselection attribute of lightning:treegrid invokes a method on js controller whenever a row is selected/deselected.
I am able to fetch the currently selected rows using the getSelectedRows() method.
But if I deselect a row, I am not able to find its Id or row data (which is deselected) in the js controller.
Aura:
<lightning:treeGrid columns="{!v.gridColumns}"
data="{!v.gridData}"
keyField="idRef"
aura:id="productTree"
expandedRows="{! v.gridExpandedRows }"
onrowselection="{! c.getSelectedRows}"
ontoggle = "{!c.handleToggle}"
selectedRows = "{!v.selectedIds}"
isLoading="{! v.isLoading }"
/>
JS:
getSelectedRows: function(cmp, event, helper) {
//get selected rows
var curRows = event.getParam('selectedRows');
//how to get the row that is deselected
}
Can anyone please help?
There is no standard way on lightning:treegrid component to obtain a list of deselected rows. There are many other limitations on this component which make it practically useless.
I followed these steps to obtain the deselected row:
Create an attribute that stores ids associated with all selected
rows. Let us name this oldSelectedRows.
Then obtain a list of all currently selected rows using
cmp.find("aura_id_of_treegrid").getSelectedRows(). Let us name it
selectedRows.
Find the difference between oldSelectedRows and selectedRows. This fetches you deselected item.

Watcher on an object is better or on its attributes?

Am creating a dynamic filter on tables just like phpMyAdmin.
Here I have created an array and used ng-repeat to have filter on multiple columns.
Initially array is empty and am pushing an object on clicking on plus button.
Now Based on user's column preference, I want to show appropriate input field like if user selects 'created_by', input field should be converted to datetime type. For this I am using a different directive where input field would be converted according to column and filter.
Thats why I want to watch column and filter of each row, which is attribute of object of that array.
var filterArr = [];
var filterObj = {
selectField: self.dictionary,
filterField: [],
column:{},
filter:{},
inputField: null,
}
//On Plus button click
filterArr.push(angular.copy(filterObj));
So each row has object structure of filterObj and out of which I want to watch column and filter.
Watcher on object of particular element is appropriate or I should use two seperate watcher on column and filter attribute?

how to add a empty string as default in the drop down where dropdown is a directive

In my AngularJS project, I am having a dropdown field as a directive and the values are coming from the backend.The user can also leave the field without selecting the dropdown(optional field) but the problem is, there is no empty field from the backend. So I need to add an empty field into the dropdown as default.
Since there is no option in the directive got struck in this issue.Googled a lot but didnt get any solutions yet.Kindly provide some suggestion.
Note:Client machine,cant post the code.
If there is no value set for the ng-model that the dropdown is bound to, Angular will provide a blank option by default that can be left in place (ignored) by the user and will result in your final value being whatever you set that ng-model to in the first place. If you need an actual empty string for the value, initialize it to that.
If you need to enable the user to select an empty value once they have already selected a value, you will need to add an empty value to the object that the dropdown is bound to. Add the empty value like this:
myPromise.then(function(data){
$scope.ddInfo = data;
$scope.ddInfo.unshift({id:'0000',text:'Not Applicable'});
});

AngularJs ui-grid how refer column defination name to add filter?

I want to set filer to a column in ui-grid dynamically using gridOptions.columnDef using column name. Right now I am only able to use number as a key.
How can I add multiple filters on a single column dynamically?
Try creating a custom filter for your grid item and then in the logic there you can do whatever you want. Something like this
field: 'myfilteredfield',
filter: {
condition: myCustomFilter
}
and in your controller
$scope.myCustomFilter = function(searchTerm,cellValue,row,column) {
};
Look here for details http://ui-grid.info/docs/#/api/ui.grid.class:GridOptions.columnDef

Setting DefaultValue of a directive field type

Please look at the following jsbin
You will notice that there are two fields. One is a normal input while the other is a new field type that references exampleDirective. Please note...in my real application, these fields are pulling pulled from JSON and are not manually added to the fields array.
I set the DefaultValue on each record within the fields array. Again, these default values are being pulled from JSON.
The RegularInput field is properly displaying the default within its input field.
The DirectiveInput is not. Please look at the model and you will see that the default value was applied to the field itself and not the input field (or fields if I had multiple) within the directive.
Is there a way to make DefaultValue work in this type of situation? And if not...what would the best way to get the value that I am pulling from JSON to be placed on the directive fields?
just update your incoming json to include the "defaultValue" in the form object that gets passed to your directive. Try this: http://jsbin.com/coyuriyazu/1/edit?html,js,output
I ended up fixing my issue by passing data INTO the directive.
formlyConfig.setType(
{
name: 'dirTest1',
template: '<div directive-test checked="to.IsChecked" amount="to.CoverageAmount"</div>'
});
With this approach, I can specify IsChecked and CoverageAmount in my directive and pass the values that I need when setting up the various inputs within the directive. So, when I push this field type to my fields array, I can easily set my values like so:
var newRow = {
key: TestKey,
type: dirTest1,
templateOptions: {
CoverageAmount: 12345,
IsChecked: true
}
};
vm.fields[i].fieldGroup.push(newRow);

Resources