This question came to my mind because I am stuck in a situation where I need to have a column which is nothing but a checkbox (this check box is not for row selection).
From backend I get values true/false and I have to map this value to this checkbox.
I am using template or cellRenderer to show checkbox in the column but value never maps to the checkbox.
Here is how I am writing the template:
template:'<input type="checkbox" ng-model="isValid"></input>'
How can I map the value to checkbox in this case?
Related
I have a kendo grid with a column consisting of radio buttons.
I want to make the radio buttons act as radio buttons(check only 1) and get the selected 1.
Here is a sample Demo
You were pretty close. First a few things about radios:
Radio buttons are grouped using the name attribute
Radio buttons are bound to labels via the for attribute on the label element matched with the id attribute on the radio button
The problem with your code is that all radios have the same id, which is why clicking any radio button toggles the first one ... because the first element found with that id is grabbed, with the assumption that there'd only be one.
In order to fix this, you need a unique id for each radio button, and you can do that by referencing the EmployeeID in the data source using the #: EmployeeID# notation, as exemplified in the docs
Therefore your template would look like this:
template: '<input type="radio" name="customer" id="customer_#: EmployeeID#" class="k-radio"><label class="k-radio-label" for="customer_#: EmployeeID#"></label>'
Please find working example here: https://dojo.telerik.com/aRuQubep/5
Hope this does the job :)
I have one dropdown lets say Drop-down A, based on option selected from that, new dropdowns will be populated. For example,on selection of option 1 from Drop-down A, 2 new dropdowns will be showed. similarly on selection of other options new dropdowns will be populated and other dropdowns will be removed.
Now when I select options from newly populated dropdowns,I can get their value.
Problem comes when I select option 1 from Drop-down A and then select values from newly generated dropdowns, but now I wish to change Drop-down A slection to option 2. Now based on current selection, new dropdowns will be generated.
So if now I post the values, my controller still shows, previous option 1 values.
So how can I change unselected dropdown values to null?
See Plunker
If I understand you problem right, I would prefer to create a function in controller to reset object.
$scope.onChange = function(){
$scope.obj = {};
}
And call it on ng-change
<select ng-model="selectC" ng-change="onChange()" name="subSub" id="main">
Wokring plunker
I use a handsontable with a checkbox column, how could I get the checkbox control from the api ?
In the documentation (DOC), you can see how to use checkbox, to change value just set true or false to the cell value with setDataAtCell().
Good luck ;)
how to get value of checkbox when checked? My problem is I alrdy had a ng-model for other stuff in my <input>
http://plnkr.co/edit/wyTRa8FVkGaEPX6BgYXb?p=preview
I want to collect the data so that when user clicked submit, I can get the value of checked checkbox.
You need to use ng-model and ng-true-value to track what you have selected.
Declare an array to track values
$scope.selectedValues=[];
Then use the following bindings
<input ng-show="showC || checked" type="checkbox" id="{{$index}}" ng-model='selectedValues[$index]' ng-true-value='{{item.name}}'>
See my updated plunkr http://plnkr.co/edit/KWh5CzZa3OcqKjjhocDz?p=preview
Just starting out with ng-grid. I need to make individual cells (i.e. for a given row and column) editable based on the boolean value of a property in my grid array. It would be great if I could simply bind to the array property to turn on (or off) cell editing. However, I don't see this option available. Did I overlook something, does ng-grid support this out of the box? If not, any suggestions as to how I could implement this feature?
I'm not familiar with something like that out of the box.
I would create a cell template for each cell and put there two divs - one div for viewing and one div for editing, and then add ng-show to each and bind it to the boolean property that indicates whether the cell is editable or not.
Example: http://jsfiddle.net/FP7Jt/
cellTemplate: '<div class="ngCellText"><div ng-show="!row.entity.edit">{{row.getProperty(col.field)}}</div>' +
'<div ng-show="row.entity.edit" class="ngCellText"><input type="text" ng-model="row.entity.age"/></div></div>'}