Hi guys, I have a couple of question regarding custom templates inside a grid.
Simpliest of all: Is it possible to have a single save button for add action without enabling edit mode?
In other words, I'd like to allow add and delete from my grid; not edit.
and I'd like to save after each add.
If I don't define the edit action (and edit transport url) I can't see any save button...
Am I doing something wrong??
now for the main question...
First of all I have to say that I'm using EF and I set it so that foreing keys are not included in the model to keep it simple and clean
(istead of having a int foireign_key_id and a class foreign_class, I just have the class in my model)
now I have a view to edit a model; this model has some list in it..
I'm working with User_Role list...
in my view I normally edit the first two fields and then I user a grid for the list..like this.
(as you can see from this code, the first question is related to this grid)
anyway, ma sub model (USER_ROLE_T007) is:
(from controller: ViewBag.FunctionsList = new SelectList(functions, "ID", "NAME");)
now the problem is that, when I save the function property is empty...
I know how to do it using the foreign key Id...I did it before, but I'd like to keep the model without them..
so, my goal is to have this list of functions which the user can add or remove (actually is link and unlink), and on add user is prompt with a drop down list conteining all functions.
is that possible?
Thanks
Fabio
Simpliest of all: Is it possible to have a single save button for add action without enabling edit mode?
In other words, I'd like to allow add and delete from my grid; not edit.
and I'd like to save after each add.
If I don't define the edit action (and edit transport url) I can't see any save button...
Am I doing something wrong??
now for the main question...
First of all I have to say that I'm using EF and I set it so that foreing keys are not included in the model to keep it simple and clean
(istead of having a int foireign_key_id and a class foreign_class, I just have the class in my model)
now I have a view to edit a model; this model has some list in it..
public
int
ID {
get
;
set
; }
public
string
NAME {
get
;
set
; }
public
string
DESCRIPTION {
get
;
set
; }
public
virtual
ICollection<OBJECT_ACCESS_T006> OBJECT_ACCESS_T006 {
get
;
set
; }
public
virtual
ICollection<ROLE_FUNCTION_T010> ROLE_FUNCTION_T010 {
get
;
set
; }
public
virtual
ICollection<USER_ROLE_T007> USER_ROLE_T007 {
get
;
set
; }
I'm working with User_Role list...
in my view I normally edit the first two fields and then I user a grid for the list..like this.
@(Html.Kendo().Grid<ROLE_FUNCTION_T010>(Model.ROLE_FUNCTION_T010)
.Name(
"Grid"
)
.ToolBar(commands => { commands.Create().Text(AcsViewRes.BtnNewFunct); })
.Columns(columns =>
{
columns.Bound(c => c.ID).Visible(
false
);
columns.ForeignKey(
"FUNCTION_T008"
, ViewBag.FunctionsList).ClientTemplate(
"#: data.FUNCTION_T008 ? FUNCTION_T008.NAME : '"
+
"empty"
+
"'#"
);
columns.Command(command => { command.Destroy().Text(AcsViewRes.SaveDestroy); command.Edit(); });
})
.Pageable()
.Sortable()
.Filterable()
.Editable(mode => mode.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.ServerOperation(
false
)
.Model(model =>
{
model.Id(v => v.ID);
model.Field(v => v.FUNCTION_T008).DefaultValue(ViewBag.DefaultFunction);
})
.Update(r => r.Action(
"LinkFunction"
,
"Function"
))
.Create(r => r.Action(
"LinkFunction"
,
"Function"
))
.Destroy(r => r.Action(
"RemoveFunction"
,
"Function"
))
)
)
(as you can see from this code, the first question is related to this grid)
anyway, ma sub model (USER_ROLE_T007) is:
[Key]
public
int
ID;
[UIHint(
"FunctionDropDownTemplate"
)]
public
FUNCTION_T008 FUNCTION_T008;
@model FUNCTION_T008
@(
Html.DropDownList(
string
.Empty, ViewBag.FunctionsList
as
SelectList)
)
(from controller: ViewBag.FunctionsList = new SelectList(functions, "ID", "NAME");)
now the problem is that, when I save the function property is empty...
I know how to do it using the foreign key Id...I did it before, but I'd like to keep the model without them..
so, my goal is to have this list of functions which the user can add or remove (actually is link and unlink), and on add user is prompt with a drop down list conteining all functions.
is that possible?
Thanks
Fabio