PDA

View Full Version : [CLOSED] Popup with grid and values from entity framework /razor/mvc



zwf
Oct 08, 2012, 9:34 AM
Hi,

I wonder if you have a sample code for a popup window with a grid with
values from entity framework, where I can doubleclick a row which then
will be entered in a corresponding textfield.
I'm working with MVC4/ EXT.NET/SVN RAZOR EF5

Any help would be nice.

Regards,
Holger

EDIT:
I want to clarify my question :
I'm having a autogenerated model from a database (EF5).
The entity classes derive from EntityObject.

In the examples I see Ext.Net.MVC.FieldAttribute.
Should I wrap all the entity-classes or is there an easy way
to use the entity classes from entity framework ?

Daniil
Oct 08, 2012, 1:46 PM
Hi @zwf,

There is a new feature that has been recently implemented - StoreFor. It allows to automatically build a Store according a data. It can also deals with Model.

Here you can find a simple example.

<Ext.Net v2 sources root>\Ext.Net.MVC.Examples\Areas\Models\Views\StoreFor\ Index.cshtml

The StoreFor method has some overloads. Please choose an appropriate one.

There is also a shortcut for StoreFor that takes Model - StoreForModel.

zwf
Oct 09, 2012, 7:26 AM
the fact, that eg.:


fp_transportierter_items.Add(
Html.X().FieldContainer()
.ID("fieldcontainer2")
.Layout("HBoxLayout")

.Items(fc1 =>
{

fc1.Add(
Html.X().TextFieldFor(m => m.ES_TRANS_NAME)
.ID("txt_ES_TRANS_NAME")
.Width(180)
.LabelAlign(LabelAlign.Top)
.FieldLabel("Nachname des Transportierten")
);

where m.ES_TRANS_NAME = "Test" in the database,
leads to a Textfield with the value "Test "
which means some 40 spaces after the value, which
makes clicking in the field in the browser a little painful.

How can I prevent this ?

Regards,
Holger

Daniil
Oct 09, 2012, 9:08 AM
I am afraid I don't understand the issue well.


which means some 40 spaces after the value

Where does these spaces come from?

Could you provide a sample to reproduce?

zwf
Oct 09, 2012, 10:00 AM
Hi,

forget about it. It something weird with EF.
After writing to the database, it adds the spaces up to the full lenght
of the field (NVARCHAR(50)).

I don't know why ......

Regards,
Holger

Daniil
Oct 09, 2012, 11:27 AM
Does the doc for NVARCHAR exactly for your database server tell anything on this? Maybe, it is documented behavior...

zwf
Oct 09, 2012, 11:47 AM
Does the doc for NVARCHAR exactly for your database server tell anything on this? Maybe, it is documented behavior...

It seems to be a feature, not a bug.
This happens, when you have nchar as datatype.
I read, that this behaviour doesn't happen with nvarchar.

I'll try this out .......

Regards,
Holger

Daniil
Oct 09, 2012, 11:51 AM
Good luck!:) It would be worth to know a result.