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

[Solved] 500 Error - Object reference not set... - when custom binding and sending a filter...

2 Answers 102 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.
vladan strigo
Top achievements
Rank 1
vladan strigo asked on 26 Jan 2010, 10:55 PM
...so the setup is:

    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .Columns(columns =>
                    {
                        columns.Add(o => o.Name).Width(100);
                        columns.Add(o => o.ShipAddress).Width(200);
                    })
            .Ajax(settings => settings.Action("_CustomBinding", "Grid"))
            .Pageable(settings => settings.Total((int)ViewData["total"]))
            .EnableCustomBinding(true)
            .Filterable()
            .Sortable()
    %>

it works like a charm....but as soon as you change the property name to include a number (any number, anywhere):

                        columns.Add(o => o.Name2).Width(100);
                        columns.Add(o => o.ShipAddress).Width(200);
or
                        columns.Add(o => o.N2ame).Width(100);
                        columns.Add(o => o.ShipAddress).Width(200);

I get from Ajax Object ref not set... on this line:

        public void Visit(PropertyNode propertyNode)
        {
            ((FilterDescriptor)CurrentDescriptor).Member = propertyNode.Name;
        }

in "FilterNodeVisitor". It says that the CurrentDescriptor is null?!


Any ideas?


Thnx!
Vladan

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Jan 2010, 09:11 AM
Hi vladan strigo,

There seems to be a bug with properties containing numbers and filtering. To fix the problem please open
'Source\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterLexer.cs'
and replace this code fragment:
private bool TryParseIdentifier(out string identifier)
{
    SkipSeparators();
 
    char currentCharacter = Peek();
 
    if (!IsIdentifier(currentCharacter))
    {
        identifier = null;
        return false;
    }
 
    StringBuilder result = new StringBuilder();
 
    identifier = Read(character => IsIdentifier(character) || character == '.', result);
     
    return true;
}
 
private static bool IsIdentifier(char character)
{
    return char.IsLetter(character) || character == '_' || character == '$' || character == '@';
}

with this:
private bool TryParseIdentifier(out string identifier)
{
    SkipSeparators();
 
    char currentCharacter = Peek();
    StringBuilder result = new StringBuilder();
 
    if (!IsIdentifierStart(currentCharacter))
    {
        identifier = null;
        return false;
    }
    else
    {
        result.Append(currentCharacter);
        Next();
    }
 
    identifier = Read(character => IsIdentifierPart(character) || character == '.', result);
 
    return true;
}
 
private static bool IsIdentifierPart(char character)
{
    return char.IsLetter(character) || char.IsDigit(character) || character == '_' || character == '$';
}
 
private static bool IsIdentifierStart(char character)
{
    return char.IsLetter(character) || character == '_' || character == '$' || character == '@';
}

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
max
Top achievements
Rank 1
answered on 28 Feb 2012, 05:58 PM
I'm having the same problem with the ForeignKey Colum, the the first and third combobox are empty and when I'm applying the filter throws the same error
Tags
Grid
Asked by
vladan strigo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
max
Top achievements
Rank 1
Share this question
or