Hello!
I want create KEY(first object in my model), before call method Create!
I dont want create KEY, If I edit object, so I can't write this:
So,probably,I need this:
How I can this do?
Because it's doesn't work :)
Please help!
And thanks for help)
I want create KEY(first object in my model), before call method Create!
I dont want create KEY, If I edit object, so I can't write this:
Events(e => e.Edit("getKey()"))
So,probably,I need this:
.ToolBar(commands =>
{
commands.Create().HtmlAttributes(new { onclick = "getKey()" });
})
Because it's doesn't work :)
Please help!
And thanks for help)
10 Answers, 1 is accepted
0
Hello Grigoriy,
To achieve this, you could bind to the edit event of the Grid and check if the current operation is Create with the isNew() method of the model.
E.g.
Dimiter Madjarov
the Telerik team
To achieve this, you could bind to the edit event of the Grid and check if the current operation is Create with the isNew() method of the model.
E.g.
.Events(e => e.Edit(
"edit"
))
function
edit(e) {
if
(e.model.isNew()) {
//custom logic
}
}
Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 05 Apr 2013, 10:56 AM
Hello!
Thanks for answer!
Can I ask you?
I need create Key = GUID when I click button "Add new object"
I use this
Wood is my Model in Grid,which have field - Key
and Next : (in popUp subGrid(Model WoodPeeling - ) I use this:
and here I need a KEY,which I create in method edit(e) : -------- here need : ParentKey = "${Key}"
but Key is ""
what did I do wrong?
In my opinion I have to call to "edit" event during initialization, but I do not know how to do it
Thanks for answer!
Can I ask you?
I need create Key = GUID when I click button "Add new object"
I use this
.Event(e => e.....)
in Grid
&
js:
function edit(e) {
if (e.model.isNew()) {
e.model.Key = guid();
}
}
and Next : (in popUp subGrid(Model WoodPeeling - ) I use this:
.Read("Select", "WoodPeeling", new { IdParent = "${Id}", ParentKey = "${Key}" })
but Key is ""
what did I do wrong?
In my opinion I have to call to "edit" event during initialization, but I do not know how to do it
0
Hello Grigoriy,
I tried to reproduce the issue, that you are mentioning, but to no avail. Could you please check if there are any JavaScript errors in the console? If you want to use the Kendo UI guid function in the current scenario, you should call kendo.guid() in the edit event handler. If you are still experiencing any issues, please send me a runnable sample project, so I could inspect it locally and assist you further.
I am looking forward to hearing from you.
Dimiter Madjarov
the Telerik team
I tried to reproduce the issue, that you are mentioning, but to no avail. Could you please check if there are any JavaScript errors in the console? If you want to use the Kendo UI guid function in the current scenario, you should call kendo.guid() in the edit event handler. If you are still experiencing any issues, please send me a runnable sample project, so I could inspect it locally and assist you further.
I am looking forward to hearing from you.
Regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 10 Apr 2013, 10:57 AM
Hello!
I attach KendoProject with My problem inside!
But I delete all script,because was need 2 mb :)
next I attach five screenshots:
console -> my new object (then I click button "Add new object") has field: ShipCountry = "GOTOCONTROLLER" (I set this value in js method , then call event edit)
index_event -> I subscribe to an event
index_isnew -> I change value ShipCountry = "GOTOCONTROLLER"
index_read_with_new_country -> It's my method read with new string Key = #= ShipCountry #
visual_studio -> but my string Key = " bla bla bla" , not "GOTOCONTROLLER"
Please Help!
I attach KendoProject with My problem inside!
But I delete all script,because was need 2 mb :)
next I attach five screenshots:
console -> my new object (then I click button "Add new object") has field: ShipCountry = "GOTOCONTROLLER" (I set this value in js method , then call event edit)
index_event -> I subscribe to an event
index_isnew -> I change value ShipCountry = "GOTOCONTROLLER"
index_read_with_new_country -> It's my method read with new string Key = #= ShipCountry #
visual_studio -> but my string Key = " bla bla bla" , not "GOTOCONTROLLER"
Please Help!
0
Hi Grigoriy,
To get the ShipCountry value in the Create Action, you could pass it to the template method when you are rendering it, just like the OrderID property.
E.g.
Wish you a great day!
Dimiter Madjarov
the Telerik team
To get the ShipCountry value in the Create Action, you could pass it to the template method when you are rendering it, just like the OrderID property.
E.g.
function
edit(e) {
if
(e.model.isNew()) {
e.model.ShipCountry =
"GOTOCONTROLLER"
;
}
e.container.find(
"#popupGridWrapper"
).html(template({ OrderID: e.model.id, ShipCountry: e.model.ShipCountry }));
}
Wish you a great day!
Regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 15 Apr 2013, 11:30 AM
Hello!
Thanks for your answer!
And I have second problem(last),similar to the previous :)
1) Grid:
Model Wood has fields: Id , Name, Key
2) Event edit:
3) EditorTemplates: (Wood)
And I want Create object in WoodPeeling with ${Key} from Wood (Key - which created , when we call method edit in Wood)
How I can this do?
Thanks for your answer!
And I have second problem(last),similar to the previous :)
1) Grid:
Model Wood has fields: Id , Name, Key
@(Html.Kendo().Grid<
Wood
>()
.Name("Wood")
.Events(e => e.Edit("edit"))
//Here other
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Wood").Window(w => w.Title("Edit")))
//Here other
)
function edit(e) {
if (e.model.isNew()) {
e.model.Key = guid();
}
}
@model Wood
<
h2
>Wood Edit</
h2
>
@Html.HiddenFor(o => o.Id)
@Html.LabelFor(o => o.Name)
@Html.EditorFor(o => o.Name)
@(Html.Kendo().Grid<
WoodPeeling
>()
.Name("WoodPeeling")
// Other
.DataSource(....
// Ajax and i.e. Read,Update and i.e
.Create("Create", "WoodPeeling", new {ParentKey = "${Key}" })
//
)
//Other
.ToClientTemplate()
)
How I can this do?
0
Hi Grigoriy,
In the current scenario, you could pass the generated guid key as a data to the template, when you are rendering it, as demonstrated in the previous post.
Dimiter Madjarov
the Telerik team
In the current scenario, you could pass the generated guid key as a data to the template, when you are rendering it, as demonstrated in the previous post.
Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 17 Apr 2013, 12:40 PM
I don't understand, how I can this do!
Because my WoodPeeling.html() does not have template (only its)
I need replace html()?
Or
push {Id : ....} ?
Because my WoodPeeling.html() does not have template (only its)
e.container.find("#WoodPeeling").html(//here:
Or
e.container.find("#WoodPeeling").getKendoGrid().dataSource //here
0
Accepted
Hi Grigoriy,
I am not sure that I understand the exact case. If the approach from the previous posts does not apply, you could use the Data method of the Grid's DataSource Action Builder, which defines a JavaScript function, that will return additional data for the Action. Please check the documentation on this topic.
E.g.
If this approach does not work in the current case, please send me the modified solution, so I could assist you further.
Dimiter Madjarov
the Telerik team
I am not sure that I understand the exact case. If the approach from the previous posts does not apply, you could use the Data method of the Grid's DataSource Action Builder, which defines a JavaScript function, that will return additional data for the Action. Please check the documentation on this topic.
E.g.
DataSource(source => source.Ajax()
...
.Create(create => create.Action(
"Create_Order"
,
"Orders"
).Data(
"additionalData"
))
function
additionalData() {
return
{
parentKey: guid()
};
}
If this approach does not work in the current case, please send me the modified solution, so I could assist you further.
All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 19 Apr 2013, 11:34 AM
Hello!
Thanks for your help!
all good works!
If I will find error, I will write)
thanks!)
Thanks for your help!
all good works!
If I will find error, I will write)
thanks!)