Update Url On Filter Gridview

Hello,

i would like to know if there is any way to update the url when applying filters on a cGridView.

This is the problem i am having now:

1- Head to /admin.

2- Apply a dropDown filter

3- Click to update one of the filtered results

4- Don’t update it and go back to the /admin.

When i’m at the /admin url i see the dropDown filter applied, but the results are not filtered.

I wonder if there is any plugin or something that works with the replaceState JS function, so every time i filter results on the cGridView the url changes and when i enter to a result, then go back i see the filter applied and the correct results filtered too.

Example:

If i execute the JS function


 window.history.replaceState('','','admin?Users[user_id]=5');

when i apply a filter, the url will change to http://yourwebsite.com/users/admin/?Users[user_id]=5

Then when i click on a filtered result, and then go back to the grid i’ll se the correct results filtered and the url will be http://yourwebsite.com/users/admin/?Users[user_id]=5

Thanks!

Hey,

i’ve been coding this js snippet.

Does the job!




$("select, input").live('change', function(){

//Check if we have changed a filter grid field

if( $(this).parent().attr('class') == 'filter-container' )

{

	var desturl = window.location.pathname,

		firstfield = false;

	$("select, input").each(function(key, val){

		if( $(this).parent().attr('class') == 'filter-container' )

		{

			if( $(this).val() == '' )

				return;

			if(!firstfield)

			{

				desturl+='?'+$(this).attr('name')+'='+$(this).val();

				firstfield=true;

			}

			else

				desturl+='&'+$(this).attr('name')+'='+$(this).val();

		}

	});

	window.history.replaceState('','', desturl);

}

});