Flex grid filters not getting applied

Posted by: vamit1112 on 24 November 2017, 6:07 am EST

    • Post Options:
    • Link

    Posted 24 November 2017, 6:07 am EST

    I am trying to apply flex gridfilters stored in localstorage but it’s not working.Please find the approach below in angularjs. Let me know the correct way of doing this.

    html :
    <wj-flex-grid
    	    control="flex.grid"
                style="height:300px"
                initialized="initialized(s, e)"
                items-source="flex.data">
                <wj-flex-grid-filter control="flex.filter"></wj-flex-grid-filter></wj-flex-grid>
    
     JS:
    app.controller('appCtrl', function ($scope) {
      $scope.flex={grid:null,
    			flex:null,
    			data:[]
    			}; 
        
     $scope.initialized = function (s, e) {
            $scope.filter.filterDefinition = localStorage['filter'];        
        }
    someapicall.then(function(data){
    	$scope.flex.data = new wijmo.collections.CollectionView(data);
    	
    	//I have tried updating the sourceCollection as seen in some posts but not 		
            working
    	[i]$scope.flex.data.sourceCollection= data;
            $scope.flex.data.refresh();[/i]
    }
    
    

    Thanks

  • Posted 26 November 2017, 9:07 pm EST

    Please go through the sample given here

    https://www.grapecity.com/en/forums/wijmo/keeping-applied-filter-val_1#wijmoarchivehiyou-will-nee

    Let me know if you are still facing issues.

    Thanks,

    Abhishek

  • Posted 27 November 2017, 6:17 am EST

    Hi Abhishek,

    I have tried this.It is still not working.In your sample, page is already loaded and we are just updating the filterDefinition, that is why it is working. But in my case, I want to apply the filter on page load. You can check my code and approach in the post.

    When the page loads I assign the filterDefinition in initialized function and api response comes after few seconds.When the response comes from the server, data is initialized and at that time filter gets clear.

    Please check and let me know if by any means we can apply the filter.

    Thanks

    Amit

  • Posted 27 November 2017, 9:08 pm EST

  • Posted 29 November 2017, 4:49 am EST

    Hi Nilay,

    I have tried that but it was not helpful.

    After a lot of efforts, I found a way. I moved the filterDefinition inside setTimeout when the api response comes. That way I was able to apply the filters.

    
    ....
    someapicall.then(function(data){
    	$scope.flex.data = new wijmo.collections.CollectionView(data);
    	window.setTimeout(function(){
    		if(localStorage['filter']){
    		 	$scope.flex.filter.filterDefinition = localStorage['filter'];	
    		}
    	},100);
    }
    ....
    
    

    Let me know if there is some other way.

    Thanks

    Amit Vishwakarma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels