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

[Solved] catch Relationships NullReference - Filter custom columns.

2 Answers 30 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.
Omar Piani
Top achievements
Rank 1
Omar Piani asked on 15 Apr 2010, 11:47 AM
I divine Telerik.

I'm studing MVC to increase development speed, i know there are many ways to avoid my problems, but i think they are slower than normal asp.net developing.

I have found this solution.
- LINQ to SQL
- Your grid without ajax support to avoid circular reference

My problem now is that when i want to show a referenced colum, in my example is TabellaNazioni (code of nation decoded with the nation name).
If this field empty is not obbligatory, or my column is imported or I have some errors, i get NullReference exception, i avoided with template column, but i cant filter, order and group the column.
<% Html.Telerik().Grid(Model) 
        .Name("Grid") 
        .PrefixUrlParameters(false) 
        .DataBinding(dataBinding => dataBinding.Server())         
        .Columns(columns => 
        { 
            columns.Bound(a => a.codicefiscale).Title("Codice Fiscale"); 
            columns.Bound(a => a.cognome).Title("Cognome"); 
            columns.Bound(a => a.nome).Title("Nome"); 
            columns.Bound(a => a.datanascita).Format("{0:dd/MM/yyyy}").Width(120).Title("Data di Nascita"); 
            columns.Bound(a => a.TabellaSesso.sesso).Title("Sesso"); 
            columns.Template(a => 
            {%><%=(a.TabellaNazioni != null ? a.TabellaNazioni.Descrizione : a.cittadinanza)%><%}).Title("Nazionalità"); 
            columns.Template(a => 
            { 
                 
                %> 
                <%= Html.ActionLink("Dettagli", "Details", new { id = a.codicefiscale }, new { @class = "ui-icon ui-icon-search"title = "Dettagli" })%> 
                <%= Html.ActionLink("Modifica", "Edit", new { id = a.codicefiscale }, new { @class = "ui-icon ui-icon-wrench"title = "Modifica" })%> 
                <%= Html.ActionLink("Elimina", "Delete", new { id = a.codicefiscale }, new { @class = "ui-icon ui-icon-trash"title = "Cancella" })%> 
                <
            }).Width(65); 
 
        }) 
        .Sortable() 
        .Groupable() 
        .Filterable() 
        .Render(); 
        %> 

Is there a fast way to resolve my problem? something like try catch in a single colum? relationship in Linq2SQL is nullable!

Thanks a lot for your software!

2 Answers, 1 is accepted

Sort by
0
Omar Piani
Top achievements
Rank 1
answered on 19 Apr 2010, 08:29 AM
up :(
0
Atanas Korchev
Telerik team
answered on 19 Apr 2010, 09:32 AM
Hello Omar Piani,

I cannot fully understand the problem you are experiencing. If there is a property which is sometimes null I suggest you use a ViewModel object and map the property to a non-nullable value. You can check this blog post which explains how to use ViewModel objects. Also you can check this blog post which shows how to avoid the circular references exception.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Omar Piani
Top achievements
Rank 1
Answers by
Omar Piani
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or