Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add extra option?
Message
De
17/09/2014 13:00:35
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01607633
Message ID:
01607739
Vues:
43
This message has been marked as a message which has helped to the initial question of the thread.
>>>>>So, that option generates bad request. Why if I change value="0" it doesn't show at all? Do you see the reason?
>>>>
>>>>It doesn't show because it doesn't get added. As to why it doesn't get added - I don't know. There's an interaction there with angular generated HTML so anything could be happening - even if you found a working solution for now there's no guarantee that a future version of angular might cause it to break.....
>>>>
>>>>Best stick with one of the solutions I suggested...
>>>
>>>I'll try server side solution. As I said, I tried JavaScript solution in the controller and again it was not added!!!
>>
>>Works for me. Are you saying unshift() didn't add it to the array or that it did but it didn't show up in the dropdown?
>
>My code was: (now commented as I went with server side option which worked)
>
>
>   //var defaultOption =  [{ id: 0, descrip: 'Select Item Tree...' }];
>                        //$scope.metaData.itemTrees.splice(0, 0, defaultOption);
>
>I saw in Developer's tools that the item was properly added to the list yet it was not shown in the drop-down!

Two problems there anyway. First don't wrap the object in an array. And IIRC it should be Descrip not descrip:
var defaultOption =  { id: 0, Descrip: 'Select Item Tree...' };
>
>
>>
>>>BTW, there will be an additional twist. In that form the item tree id will be required (not 0) for some cases and non required (can be 0) for other cases.
>>>
>>>Do you know what will be the best way to handle this scenario? Should I do something like
>>>\ng-required = "someFunction()" for this and in that function check for 0 in the value?
>>
>>Not entirely sure what you mean but if you don't want the option to be available then isn't it simpler (and more intuitive for the user) just to remove it on the client side - or just don't add it in the first place. Failing that the I'd think a directive might be better than ng-required ?
>
>On that form there is another drop-down for the Salespoint Type. Certain types don't require item tree selected but most types require a selection. So, I am thinking how I should implement this. The non-0 item tree requirement is only for certain types and I am selecting the type.

So you have multiple selects bound the same source ?
In that case a directive is definitely the best option....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform