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

[Solved] Bug in Beta for MVC Grid Custom Commands when column sorted

0 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 1
Bill asked on 09 Nov 2011, 08:34 PM

UPDATE - I hate when I find a solution 30 mins after I post.  The very last thing in the documentation for custom commands is this ".SendState(false)", which prevents the issue I'm having.  But it still might be nice to have the grid look into the related hierarchy when sorting.

MVC3, EF4.1, Repositories
Win 7 64bit
IE8 and Chrome
Telerik Q3 Beta 2011.3.1027
C#

Telerik,

I'm fairly certain I've found a bug in the new MVC Grid Custom Commands feature, but I'm not sure if I've attempted to implement something unsupported, or if this bug exists because of sorting/filtering and then using the custom command to change the controllers and model.  I did not want to waste a support ticket on this because this is a beta feature. 

The short description of the problem is that it appears when you use a custom command to change the controller and model, and a grid exists in the new model, the orderBy attempts to execute on the new model and it will fail if the field doesnt exist directly in the new model. 

When the grid sends 'GET' command to the server for the custom command, it includes the field name if its sorted, but if that field is a derived from a related object or doesn't exist directly in the new model, I will recieve an error like this:

Invalid property or field - 'LoginId' for type: u2UserRole

My presumpion is that the Telerik Grid is not aware that I've changed models and is throwing this error because it doesn't see it in the new/current model.  My request is that the grid should ignore the orderBy and filterBy commands if the field is not present in the model instead of throwing this error.  Can you add this to PITS?

The custom command action works perfectly as long as I dont click the button when the column is sorted.  Below are the two GETs that are issued from the same custom command action.  The first being successful because 'OrderBy=' is nothing.  The second failed because 'OrderBy=LoginId-asc'.  Since I cannot include a test project for you, I will explain a little more detail.  There are 3 tables, u2User, u2Role, and a many to many table inbetween called u2UserRole that has only FKs to the other 2 tables. Im using a custom command at the u2User/Index to call the Index action with a User Id at the u2UserRole controller, so I can make User / Role associations. There is a grid on the page that shows the user and his Roles, and coincidentally it does have a LoginId on it, but the grid is bound to a u2UserRole object which binds to the LoginId like this ".columns.Bound(o => o.u2User.LoginId)".  So this leads me to believe the grid does not look at related objects when trying to execute the OrderBy. Perhaps it should if it doesnt find it on directly?  I've include my Index files.

  1. Request URL:
    http://localhost:60992/u2UserRole/Index/50671daf-3ff4-e011-9cb4-0016356d24f9?page=1&orderBy=&filter=&u2UserId=50671daf-3ff4-e011-9cb4-0016356d24f9
  2. Request Method:
    GET
  3. Status Code:
    200 OK
  1. Request URL:
    http://localhost:60992/u2UserRole/Index/50671daf-3ff4-e011-9cb4-0016356d24f9?page=1&orderBy=LoginId-asc&filter=&u2UserId=50671daf-3ff4-e011-9cb4-0016356d24f9
  2. Request Method:
    GET
  3. Status Code:
    500 Internal Server Error
  4. Request Headersview source

    Tags
    Grid
    Asked by
    Bill
    Top achievements
    Rank 1
    Share this question
    or