This is a migrated thread and some comments may be shown as answers.

Sorting and filtering on Viewmodel property that was flattened in api

5 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karamjit
Top achievements
Rank 1
Karamjit asked on 24 Jan 2014, 03:25 AM

I am trying to understand how can provide sorting & filtering on a column of view model that was flattened.

VMAddress
addressid
street1
street2
countryid
CountryName
stateid
StateName
cityid
CityName

The Coulumns CountryName,StateName and CityName as flattened fro their respective table ( i.e Country.CountryName, State.StateName,City.CityName).

If i filter or sort on this columns nothing happens. since i don' have those fileds as column in the database.

How can shift the filter on the server to other columns ?

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Jan 2014, 06:41 PM
Hello Karamjit,

You should map the descriptor field names back to the original ones(CountryName - Country.CountryName) in order for the operations to work correctly. 

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Karamjit
Top achievements
Rank 1
answered on 31 Jan 2014, 01:52 AM
Did not quite get it. Do you have some working example ?
0
Daniel
Telerik team
answered on 03 Feb 2014, 03:09 PM
Hello again,

What I meant was to convert the names of the fields that you are sorting and filtering on back to the correct ones for the underlying data. I am not sure if the example will be useful since I do not know how are you performing the operations or what server side technology are you using but I am attaching the Grid WCF CRUD code library project modified to map the fields back to the original ones before performing the sorting and the filtering on the server.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Karamjit
Top achievements
Rank 1
answered on 04 Feb 2014, 05:33 PM
TO simplyfy the question. I am using Drop down on an a Foregin Key that is CountryID, the Dropdown is displaying the Name of Country
If i enable Sorting and filtering on this column, it is sorting and Filtering by CountryID, i want the Sorting and Filtering to done by CountryName.

Also i am using JQUERY(NO MVC). on the Server Side i am using WebAPI Odata. staying within the confinements of this technology i would like to see how to achieve that.

Combobox is using the following WebAPI method  

public PageResult<Country> GetCountries(ODataQueryOptions<Country> options)
        {
            IQueryable results = options.ApplyTo(db.Countries);

            return new PageResult<Country>(
                results as IEnumerable<Country>,
                Request.GetNextPageLink(),
                Request.GetInlineCount());
        }





0
Daniel
Telerik team
answered on 06 Feb 2014, 03:34 PM
Hello,

In that case I can suggest to bind the column to the text field. It is also possible to replace the filter field names in the parameterMap function but the filter menu will still be using inputs and operators for the CountryID field type and not for Name.


Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Karamjit
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Karamjit
Top achievements
Rank 1
Share this question
or