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

Grid with key-less db table

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Duke
Top achievements
Rank 1
Duke asked on 27 Feb 2017, 03:53 PM

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.

1 Answer, 1 is accepted

Sort by
0
Duke
Top achievements
Rank 1
answered on 27 Feb 2017, 05:05 PM

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.

 

 

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