I'am working with Adobe AIR application and i have a registration form which contains a combobox which consist of 2 values...i want to store the selected value to a variable..
here is the code..
var a:IList = new ArrayCollection(['Nurse','Patient']).list;
selectbox.dataProvider =a;
suppose if it was a textbox,we can store the value like this:-
var lastname:String = textbox2.text;
in the same way how can i store the selected value from combobox...?
Thanks
You'll use the selectedItem property:
var role:String = selectbox.selectedItem;
P.S. Welcome to StackOverflow! If you find my answer helpful, please be sure to 'accept' it by clicking the green checkmark to the left.
Related
I am using a kendo ui batch edit grid and I want to use a dropdown as a column of it.
I read other topics about this subject and I did these steps:
1- I created a list of text/value and named it as
DocumetTypesSelectList in a viewbag like this:
ViewBag.DocumetTypesSelectList = DocumentTypesBll.GetDocumentTypes().ToList().Select(item => new SelectListItem
{
Value = item.DocumentTypeId.ToString(),
Text = item.Title
}).ToList();
2- I Cast the viewbag as a list of SelectItems in my view like this:
var DocumetTypesSelectList = ViewBag.DocumetTypesSelectList as List<SelectListItem> ?? new List<SelectListItem>();
3- I added a column to grid as follows:
columns.ForeignKey(p => p.DocumentTypeId, (System.Collections.IEnumerable)DocumetTypesSelectList, dataFieldText: "Text", dataFieldValue: "Value")
but it does not open to select on of the items. on click you can change the value, and off click it shows the text using DocumetTypesSelectList .
Thanks In Advance
many thanks for your help
Please explain little bit more about
on click you can change the value, and off click it shows the text
It seems that here (System.Collections.IEnumerable)DocumetTypesSelectList you have missed your DocumetTypesSelectList object to pass on properly. You can do this in your controller by using ViewBag as ViewBag.DocumetTypesSelectListEx = DocumetTypesSelectList and use this ViewBag in your view as (System.Collections.IEnumerable)ViewBag.DocumetTypesSelectListEx
Second thing is, in your DocumetTypes you must have two fields one is for value and one is to display. It seems you have both as "Text" and "Value". Also check the demo here
I hope someone can help me with this, It's a strange question maybe as I didn't find an answer online.
I call the database and retrieve a list (in json) of items.
Then in angularjs,I render this list by extracting relevant pieces of data(name,age,etc) and show it properly in a table as a list of rows.
I have then an edit button that takes me to another page where I want to put a dropdown list.
What I want to know if is possible to add to that dropdown list the rendered list I previously created in my previous page.
is it possible to save the previously rendered list in a variable and then use that variable in the dropdown?
thank you
You could store the list within a controller and make this data availablte to this dropdown, I think.
Instead of trying to query for the list, add the list to the template, get the list from the template and render somewhere else, I'd suggest query for the list, save the list in a service , and then when you want to use that list again, get it from the service. Something like:
service:
var services = angular.module('services');
services.factory('getListService',['$http',function($http){
var getListOfStuff = function(){
//call to database
return //your json
};
var extractNameAgeEtc = function(){
var myListOfStuff = //get list of stuff from $http or database
var myListOfNameAgeEtc = //make a list of tuples or {name,age,etc} objects
return myListOfNameAgeEtc;
};
return {
extractNameAgeEtc : extractNameAgeEtc
};
}]);
controllers:
angular.module('controllers',['services']);
var controllersModule = angular.module('controllers');
controllersModule.controller('tableRenderController',['getListService','$scope',function(getListService,$scope){
//use this with your table rendering template, probably with ng-repeat
$scope.MyTableValue = getListService.extractNameAgeEtc();
}]);
controllersModule.controller('dropdownRenderController',['getListService','$scope',function(getListService,$scope){
//use this with your dropdown rendering template, probably with ng-repeat
$scope.MyDropDownValue = getListService.extractNameAgeEtc();
}]);
I am using the SSRS 2008r API to create and manage SSRS from a webform application. When creating a folder I see where I can add a folder name as well as specify additional meta data (custom properties) that can be a part of the folder. My question is how do I populate additional fields in the catalog database via the api. When I look at the CreateFolder method the only properties I can add at the insert are folder name, path, and custom properties:
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
However I would also like to set at this time the description, and hidden value.
I'd appreciate any suggestions on how this is accomplished. Every example I have seen within MSDN only shows setting the folder name, path, and custom properties.
thanks in advance
Set the item properties (Description and Hidden) by initializing a Property class for each. Never done it before, but I'm guessing it would look something like this (assuming C#):
...
// description property
Property description = new Property();
description.Name = "Description";
description.Value = "Your description here.";
// hidden property
Property hidden = new Property();
hidden.Name = "Hidden";
hidden.Value = "True"; // not sure on value here, may be True/False, Yes/No
// build properties array
props[0] = description;
props[1] = hidden;
// create folder
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
Apologies if this has already been mentioned or answered but I have looked for a few days and cannot work this out. I am new to both Knockout and StackOverflow so bear with me please.
I am working with CakePHP and have some JSON returned from my controller which is in the following format
{"countries":[{"Country":{"id":"1","country":"England"}},{"Country":{"id":"2","country":"Wales\/Cymru"}},{"Country":{"id":"3","country":"Scotland"}},{"Country":{"id":"4","country":"Republic of Ireland"}},{"Country":{"id":"5","country":"Northern Ireland"}}]};
I am hoping to have the above counties appear as an item in a select statement with the value being set to 1 and the text displayed as the country. However I cannot seem to get knockout to do this for me. I am sure this is a simple question to those familiar with knockout but I cannot understand what to do all I see is the list of objects but do not know how to access the object properties on the data-bind
HTML
<select data-bind="options:countries, optionsText:'Country'"></select>
Javascript
var viewModel = {};
var data = {"countries":[{"Country":{"id":"1","country":"England"}},{"Country":{"id":"2","country":"Wales\/Cymru"}},{"Country":{"id":"3","country":"Scotland"}},{"Country":{"id":"4","country":"Republic of Ireland"}},{"Country":{"id":"5","country":"Northern Ireland"}}]};
var jsData = ko.mapping.fromJS(data);
ko.applyBindings(jsData);
I have created a simple JSFiddle http://jsfiddle.net/jbrr5/14/ to show what is happening any help would be appreciated with this small challenge
Your data has an odd structure. It's like this:
- countries
- Country
- id
- country
The actual id and country is another level deep in the array of countries. You'd have to do some hacking around just to get those to appear in the select element as-is. It would be better if you just mapped to the inner Country objects.
var mappingOptions = {
'countries': {
'create': function (options) {
// map to the inner `Country`
return ko.mapping.fromJS(options.data.Country);
}
}
};
var viewModel = ko.mapping.fromJS(data, mappingOptions);
ko.applyBindings(viewModel);
Updated fiddle
You have very complex structure of array. For your case you have to write 'Country.country' in options binding but it doesn't work because binding cannot parse such complex expression. Instead of using options and optionsText bindings you can use foreach:
Here is working fiddle: http://jsfiddle.net/vyshniakov/jbrr5/18/
But I would recommend you change structure of your data to
{"countries":[{"id":"1","country":"England"}]};
or map data accordingly. In this case you could use options binding:
<select data-bind="options:countries, optionsText:'country', optionsValue:'id'"></select>
I want to update the lists in the bean when the user transfers an item from one list to another. Is there a way to do that?
Thx.
In the xhtml:
<p:pickList value="#{myBean.myDepartment}" onTransfer="handleTransfer(e)"....>
In the bean:
List<Department> selectedDepartments = new ArrayList<Department>();
List<Department> availableDepartments = getAvailableDepartments();
private DualListModel<Department> myDepartment;
myDepartment = new DualListModel<Department>(availableDepartments, selectedDepartments);
On Commit, Departments selected by the user can be accessed using selectedDepartments
And the script ...
<script type="text/javascript">
function handleTransfer(e) {
item = e.item;
alert(item.text());
fromList = e.from;
toList = e.to;
type = e.type; //type of transfer; command, dblclick or dragdrop)
}
</script>
I don't exactly know what do you want. This is done automatically same as if you type something into p:inputText it is available in beans property representing the value of p:inputText without need of manual update.
Just access the updated values in your pickList with getTarget() or getSource() methods. You are probably trying to access lists which you provided to DualListModel directly like:
DualListModel<fooType> fooModel = new DualListModel<fooType>(fooList1,fooList2);
// transfer item
// check if fooList2 is updated - this is wrong, it is **not** updated
fooModel.getTarget(); // this way you can get the actual values of target list
target - right side, source - left side of a pickList.