Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Byte column type - drop down doesn't show correctly
Message
 
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01606733
Message ID:
01606798
Views:
34
>>Hi everybody,
>>
>>In the view model I have the following:
>>
>>
>> [DisplayName("Template Type:")]
>>        public TemplateTypes TmplType { get; set; }
>>
>>where the TemplateTypes enum is Byte type (column in the database is tinyint). I tried using byte directly with the same result.
>>
>>In the form we have the following:
>>
>>
>><div class="col-md-8">
>>                @*@Html.DropDownList("templateTypes", (IEnumerable<SelectListItem>)ViewBag.TemplateTypes, new { @class = "form-control", ng_model = "currentTemplate.tmplType" })*@
>>                <select class="form-control" name="templateTypes" id="templateTypes"
>>                        ng-model="currentTemplate.tmplType" 
>>                        ng-options="t.value as t.text for t in templateTypes"></select>
>>            </div>
>>
>>The original commented code worked Ok. The new code has the values in drop down when I open it, but it doesn't correctly show on the form (e.g. drop down shows empty). If I change the value, it does correctly show in the grid after I save, but not in the form - the drop down is still blank.
>>
>>The same form has few more drop downs and they show everything correctly.
>>
>>To build the templateTypes we use a special class to convert enums into value and string representation.
>>
>>Do you see what may be missing here? Could it be the types difference (both value and text are strings)?
>>
>>
>>     public string Text { get; set; }
>>        //
>>        // Summary:
>>        //     Gets or sets the value of the selected item.
>>        //
>>        // Returns:
>>        //     The value.
>>        public string Value { get; set; }
>
>Sounds like it should work - here (AFAICS) is a stripped down version without problems:
<!DOCTYPE html>
><html data-ng-app="MyApp">
><head>
>    <meta name="viewport" content="width=device-width" />
>    <title>Index</title>
></head>
><body data-ng-controller="myCtrl">
>    <div>
>        <select name="templateTypes" id="templateTypes"
>            data-ng-model="tmplType"
>            data-ng-options="t.Value as t.Text for t in templateTypes">
>        </select>
>        <input type="text" data-ng-model="tmplType" />
>    </div>
></body>
>
><script src="~/Scripts/angular.js"></script>
><script type="text/javascript">
>    var app = angular.module('MyApp', []).controller('myCtrl', ['$scope', function ($scope) {
>
>        $scope.templateTypes = [];
>        $scope.templateTypes.push({ Text: "One", Value: "1" });
>        $scope.templateTypes.push({ Text: "Two", Value: "2" });
>        $scope.templateTypes.push({ Text: "Three", Value: "3" });
>
>        $scope.tmplType = '';
>    }]);
></script>
></html>
What's different ?

I tried saving your code into HTML (I substituted call to angular.js with CDN google version), but nothing at all showed up.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform