I was able to attach the file.

On Monday, September 28, 2015 at 1:40:05 PM UTC-5, rsford31 wrote:
>
> Hi, On my page I have a drop down for the FoodType and a grid for the 
> Food. When the user selects a FoodType the associated Food is displayed in 
> the ng-grid. This works.
>  When the user logs in and it has their default food type id associated 
> with their user name. 
> When the page first loads though, the default food type displays in for 
> the drop down but all the food displays in the grid. Only the food 
> associated with the default food type should be displaying.
>  The filterText set for the filterOptions in the grid is using the 
> selected food type. When I did some checking the selected food type is 
> undefined. I tried attaching a text file with the code but got nothing but 
> a blank screen with "Upload" on the side. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
In the HTML:
<select ng-model="vm.selectedFoodType"
                        ng-options="foodType.Id as foodType.Name for foodType 
in vm.foodType"
                        ng-change="vm.foodGridOptions.filterOptions.filterText 
= vm.selectedFoodType ? 'FoodTypeId:' + vm.selectedFoodType : ''"
                        class="form-control">
                    <option value="">- Select Food Type -</option>
                </select>

In the js file:
...
vm.foodGridOptions = {
        data: 'vm.food',
        enableRowSelection: true,
        multiSelect: false,
        columnDefs: [
            { field: 'FoodTypeId', displayName: 'FoodTypeId', visible: false },
            { field: 'Name', displayName: 'Food', minWidth: 250, width: 'auto', 
resizable: true },

        ],
        filterOptions: { filterText: vm.selectedFoodType, useExternalFilter: 
false },
        sortInfo: { fields: ['vm.food.Name'], directions: ['asc'] },
        afterSelectionChange: function (rowItem) {
            if (!rowItem.selected)
                return;

            vm.importLog = rowItem.entity;
            vm.appyDisabled = false;

        }
    };

...
activate();
 function activate() {
            var promises = [getDefaultFoodType(), getFoodType(), getFood()];
            common.activateController(promises, controllerId);
           
        }

function getFood() {
        return datacontext.getFood()
            .then(function (response) {
                return vm.food = response.data;
            })
            .catch(function (exception) {
                logError('Call to Get Food Failed.' + 
exception.data.ExceptionMessage, null, true)
            });
    }


function getFoodType() {
        return datacontext.getFoodType()
            .then(function (response) { return vm.foodType = response.data; })
            .catch(function (exception) { logError('Call to Get Food Type  
Failed: ' + exception.data.ExceptionMessage, null, true) });
    }



 function getDefaultFoodType() {
        return datacontext.getUser(user.username)
            .then(function (response) {
                vm.selectedFoodType = response.data.DefaultFoodTypeId;
            });
    }

Reply via email to