Grid with key-less db table

2 posts, 0 answers
  1. Duke
    Duke avatar
    21 posts
    Member since:
    Dec 2016

    Posted 27 Feb 2017 Link to this post

    I'm trying to use a grid with an existing db table that can't be altered.

    There's no key, just a CAR_CD and CAR_DESC, both defined as strings.

    In my datasource, when I don't specify a model.Id (like below), I get an error "There is no DataSource Model Id property specified."  in the Visual Studio debugger.  It's looking for an Id.

    .DataSource(dataSource =>
            dataSource.Ajax()
            .PageSize(50)
            .Batch(true) // Enable batch updates
            .Model(model =>
            {
                model.Field(car => car.CAR_CD).Editable(true);
                model.Field(car => lob.CAR_DESC).Editable(true);
            })

     

    SO... I change the CAR_CD to an Id (see below) and then get "CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type".

    {
                model.Id(car => car.CAR_CD).Editable(true);
                model.Field(car => lob.CAR_DESC).Editable(true);
            })

     

    Is there an easy way to use a natural key (CAR_CD + CAR_DESC)?  I can test them for uniqueness in the .net code, but I need to get the grid to function.

     

    Thanks.

  2. Duke
    Duke avatar
    21 posts
    Member since:
    Dec 2016

    Posted 27 Feb 2017 in reply to Duke Link to this post

    Solved.  For those wondering, the culprit is this line: 

    model.Id(car => car.CAR_CD).Editable(true);

    Removed the Editable fluent filter, so it is simply

    model.Id(car => car.CAR_CD)

    Strangely, if anyone can clarify this for me, the column remains editable in the grid.

     

     

     
     
     
Back to Top