Remove Blank option on Angular on dynamic option objects - css

I have this code
<select ng-model='item.data.choice' >
<option ng-if='item.data.simple_allow_blank == false' ng-show='choice.name' ng-repeat='choice in item.data.simple_choices' value="{{choice.name}}" ng-disabled="$parent.controllerAction == 'show'">{{choice.name}}</option>
</select>
It shows the 3 choices entered by the Admin of the system in a dropdown box. It shows it without the blank choice.
The problem is if I want to put a default value (for example, choice[0]), it adds a blank value.
Also when converting from ng-repeat to ng-options from this question.
I have 4 choices 1,2,3 and blank i wanted to remove the blank i followed the guide/answers found on the link i have posted with my question, the difference in my part is that i have a dynamic list and when the list is newly created. it never fails to include the blank when using ng-option but it solves my problem to have an initial default value from the dynamic list, if i use ng-repeat i dont have the initial value but the blank from the choices where remove. i wanted to have the blank choice remove and the same time to have an initial value from the dynamic list.
I can set the default value but it cannot remove the blank option.
Can anyone help? Thanks.

You have to filter data in js file and create a new array that you will render it in html.let say you are getting data in variable **item.data.simple_choices**(as you have written it in ng-repeat)then your function would be.
var data = item.data.simple_choices;
var filteredArray = [];
data.filter(function(item){
if(item.name!=''){
filteredArray.push(item)
}
})

After hours of leeching the web and lots of trial and error I finally got the correct answer.
<select ng-model='model'>
<!-- correct binding -->
<option ng-show='choice.name' ng-repeat='choice in object' value="{{choice.name}}" ng-selected='model = object[0].name'>{{choice.name}}</option>
</select>
The code is simple but this format is helpful because object is an object the has the value of the list. as you can see i did assign it to the model because model is the variable that is being used in the view. The [0] is the index number of the list. You can use value or name depending on what parameters are present on the object.

Related

Display label based on, field on one data-source (singular) being within another data-source fields many

I am still learning, and looking for help on how to display a label based on one data-sources field value, being within another data-sources field value list.
I have one calculated table, displaying rows of documents within a folder, and wish to use a field representing the document number in that data-source, so that if it's ANYWHERE within another tables field it displays my label.
I've been trying to use projection as I think this is how to achieve it.
I can get it working based on both the current #datasouce.item.fieldnames but need it to base the calculation on all possible numbers in that tables field (Image below should make it easier to understand).
I expect that it has something to do with projections, but can't find anything within the learning templates or anywhere else to resolve the issue.
I think the following should work for you. For the 'Reserved' label have the following binding for the text property:
(#datasources.project_quotes.items..quotenumber).indexOf(#widget.datasource.item.Qnumber) !== -1 ? 'Reserved' : ''
I would suggest alternatively just to include a field in your calculated datasource and making the determination in your server script.

Select2 multiple select passing key,value pairs on postback

I am using Select2 Tags using a dropdown as well as a direct input and have the following code in my View:
<select id="lessonTags" class="form-control" multiple="multiple" style="width:100%" name="SelectedTags">
#foreach (var lesson in Model.Lessons)
{
<option value="#lesson.Id">#lesson.Title</option>
}
In my viewmodel I just created a temp variable string[] SelectedTags which gives me the string of what was selected via the dropdown as well as anything that was typed in that was not in my original options.
So currently I have to loop through my data and match to see if the SelectedTags array has a match on my db, if it does then I can use that Id in my model, if it doesn't exist then I have to Create that lesson in my DB.
I find this to be extra processing, it would be nice if I can just pass say a key, value pair of ID/Lesson.Title and anything that I typed wouldn't have an ID so I can easily identify what needs to be created on the DB.
Is there a way to pass the key/value pair via the name tag?
EDIT: Currently whats getting returned is the lesson.Id if its in the list or the actual text if its not - the issue with this is if the user types in a number, i can't discern between an Id and the users number...hence I am thinking I need to somehow flag a new piece of data.

Using 'Filter by Column Value' and multi column filtering using a java vector - xPages

I have an xPage which I have built with 3 combo boxes and 1 view control. I would like to use the 'Filter by column value' option within the view control to provide the options to filter the values, allowing the user to display any combination of the combo boxes. e.g. Only comboBox1, or comboBox1 and comboBox2, or comboBox3 only, or comboBox1 and comboBox2 and comboBox3.
I used the example in the 'xPages Demonstration Application' (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpagesdemoapp.htm or http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=AAC8E26599256FDC852578CB0066CC13) to do the multi-column filtering using a vector of non-categorized columns.
So, I have come across what appears to be a fairly major issue whereby the data needs to be sorted by date. Date is not one of the filters, but it needs to be the first column in order for the data to be sorted correctly. So my first column is a string, YYYYMMDD, to ensure the data is sorted correctly. I tried to use the sort option within the view control and that does not appear to work with the column filtering implemented in this manner.
So, as Date one of the criteria I am filtering by, I have passed that as an empty string - using the thought process that an empty string will select all (as in the url examples above).
The code I have used to do the filtering is:
var vtr:java.util.Vector = new java.util.Vector();
var t1 = sessionScope.Email;
var t2 = sessionScope.Own;
var t3 = sessionScope.Module;
vtr.addElement("");
#If(sessionScope.Own=="My calls",vtr.addElement(t1),vtr.addElement(""));
#If(sessionScope.Own=="My calls",vtr.addElement(""),vtr.addElement(t2));
#If(sessionScope.Status=="Open",vtr.addElement("Open"),vtr.addElement(""));
#If(sessionScope.Module=="All",vtr.addElement(""),vtr.addElement(t3));
return vtr;
What I have found is that not all data is being returned. I thought this might be due to the date field. So I removed it (changing the view and removing the first add element), and yet I still find that not all data is being returned. I suspect that this might be due to the empty strings being passed, or, that this does not actually work the way I had hoped.
Does anyone know if I can get this working the way I want it to, and if not, do you have any suggestion on how I can go about this?
Date is not needed as the first sortable column in the view. The first column does need to be sorted for the lookup to work just like the Notes view needs to be sorted for #DbColumn and #DbLookup to work. XPages uses the same underlining architecture. This example - http://dev.openntf.org/demos/demoapp.nsf/viewFilteringVector.xsp - works without the data being sorted by Date.
My guess as to why your example isn't working is down to how your Notes view sorted. Try creating a new view with column 1 (email) ascending sort, column 2 (own) ascending sort, and column 3 (module) again ascending sort. You should be able to get vector filtering working in this situation.
If all that doesn't work for you, you might consider multi-layer category filtering (new to 853). This filtering type in XPages is related to how categoryFilter works but allow you to filter a view by the sub-category (or sub-categories) too. This technique might suit your scenario better. Hope this helps.

Selenium IDE : how to verify that only specific values are present in a drop down list

I hope someone is able to help me. I am trying to determine whether or not Selenium IDE can verify that only specific values are present in a drop down list, and should anything else appear within the drop down list it is an error.
For example, using a basic html Single Select drop down list :
<select id="drop_down_list">
<option value="Test">Please select...</option>
<option value="Saab">Saab</option>
<option value="Mercedes">Mercedes</option>
<option value="Audi">Audi</option>
</select>
I know I can verify the 'Label' of each selectable value using (for example) :
verifySelectedLabel : //select[#id='drop_down_list'] : Please select...
I know I can verify the 'Value' of each selectable value using (for example):
verifySelectedValue : //select[#id='drop_down_list'] : Test
And I know I can do this for each other selectable value displayed.
But what if for whatever crazy scenario, a Dev decided to add 'Ford' to the drop down list, and he/she did not make anyone aware of this ? My tests would pass as those selectable values which I am expecting are still present.
Is there is a way of verifying that no other values other than those I am expecting are also contained within the drop down list ?
I know there is 'verifyNotSelectedLabel' and 'verifyNotSelectedValue' available for use, and these work perfectly when I can specify the 'Labels' and 'Values' accordingly, but they dont help in this particular scenario.
Fingers crossed someone can help, many thanks in advance to all,
How about using "verifySelectOptions", this will check all the options in the dropdown exactly how it should appear.
So in case if there is a New value added or some changes in the existing values (like spelling mistake etc) Step will fail.
If you right click on the dropdown list while in Selenium-IDE, try choosing verifyTextPresent from the command list. The value will be a text list of all the options in the list strung together(usually with spaces between).
Then if a developer adds a selection(or misspells an existing selection, the step will fail(you could use assertTextPresent if you want the test to stop at that point).
Klendathu

Asp.Net, Dynamic Data Website, Foreign key One to One relationship, DropdownList, how to customise?

I'm using Asp.Net's Dynamic Data Website project type.
I've created a db that has one to onerelationship between two tables specified using a foreign key, (this could be one to many but I've used the linq designer to change it to a one to one relationship).
i.e. I have a table Invoice and table CreditNote that takes an Invoice_Id as a foreign key
I was hoping that when I navigated to CreditNotes/Insert.aspx that it would display the a list of InvoiceIds in a dropdown list. It almost does this - it creates dropdownlist but only populates option value and not the text so I get something like this in the html source (notice only the value is populated - which looks empty to the user):
<select>
<option value="someInvoiceId"></option>
<option value="someInvoiceId"></option>
</select>
Can anyone tell me how I could fix this?
Thanks in advance for any help!
Hey I just stumbled over this question look for another answer but I think that you might need to set up some more meta data on your model such as the adding attributes so that you can define which field should be used
http://ericphan.info/blog/2009/2/24/aspnet-dynamic-data-display-custom-text-in-a-foreign-key-dro.html

Resources