This question is locked. New answers and comments are not allowed.
Hello.
With the last update to the Telerik's extensions for MVC I was happy to see you implemented ModelState support on ajax grids. That's a good update, but it has brought some problems for my application. This is the most important one:
I have entities with an Id column. This column is long. The column is used to as main key for the grid, but there's no column for it, as it's not edited. It's generated at INSERT time by the database, so I don't mind it's value when I create a new record.
Ok, since the last update, none of my ajax grids inserts records, because it tells me that the Id column cannot be null... this column, as I stated, is not present at the grid, so I guess you're checking ModelState.IsValid generally instead of checking ModelState for the columns present in the grid, what should be the case... If there are any other errors in the model, I can handle them in my controller, as I do, so while my controller saves the new record, the grid stays in insert mode, and no error is given.
The roundabout I found for this is adding the Id column in the grid, but I don't want it to be visible. If I set it to "Visible(false)" it doesn't even render, so the same error comes up.
The second thing I tried is adding the column with HtmlAttributes(new { style = 'display:none' }) but then, the Id itself doesn't show but the header for the column "Id" is there with a blank column.
My third intent is to make .Width(0) for the colum, but then when I edit the grid, all the columns widths break and the visual for the grid is a mess.
My fourth intent was to place that column the last, then it worked... but only for grids that have .Scrollable property. If you don't set the grid scrollable, then the header appears with a blank column (no ids are showed) as in the second solution I tried.
Please, can you confirm me if this ModelState check is as intented, and what to do when we don't place columns in the grid that can invalidate modelstate? I think I should have the decision on what to validate and when....
If it must be this way (weird), please tell me how to make a column invisible, but posteable so the model don't fail at postback.
Thanks!!!
With the last update to the Telerik's extensions for MVC I was happy to see you implemented ModelState support on ajax grids. That's a good update, but it has brought some problems for my application. This is the most important one:
I have entities with an Id column. This column is long. The column is used to as main key for the grid, but there's no column for it, as it's not edited. It's generated at INSERT time by the database, so I don't mind it's value when I create a new record.
Ok, since the last update, none of my ajax grids inserts records, because it tells me that the Id column cannot be null... this column, as I stated, is not present at the grid, so I guess you're checking ModelState.IsValid generally instead of checking ModelState for the columns present in the grid, what should be the case... If there are any other errors in the model, I can handle them in my controller, as I do, so while my controller saves the new record, the grid stays in insert mode, and no error is given.
The roundabout I found for this is adding the Id column in the grid, but I don't want it to be visible. If I set it to "Visible(false)" it doesn't even render, so the same error comes up.
The second thing I tried is adding the column with HtmlAttributes(new { style = 'display:none' }) but then, the Id itself doesn't show but the header for the column "Id" is there with a blank column.
My third intent is to make .Width(0) for the colum, but then when I edit the grid, all the columns widths break and the visual for the grid is a mess.
My fourth intent was to place that column the last, then it worked... but only for grids that have .Scrollable property. If you don't set the grid scrollable, then the header appears with a blank column (no ids are showed) as in the second solution I tried.
Please, can you confirm me if this ModelState check is as intented, and what to do when we don't place columns in the grid that can invalidate modelstate? I think I should have the decision on what to validate and when....
If it must be this way (weird), please tell me how to make a column invisible, but posteable so the model don't fail at postback.
Thanks!!!