I am using Kendo Grid for ASP.NET MVC in Server Edit mode. The grid is bound to a List<ModelObject>. I am using a Popup Editor. For the popup editor I am using a custom template. The ModelObject has some properties that should be loaded only when editing (lazy load). I have looked for samples but did not find how I can do lazy loading.
Are there any samples I can look at to get some ideas?
Thank you
Are there any samples I can look at to get some ideas?
Thank you
5 Answers, 1 is accepted
0
Hello Gary,
The standard approach for achieving this in an Ajax bounded grid is to bind to the edit event and check if the current model is new or edited. Since this event is not fired in the current scenario, you should parse the get parameters to check the current grid mode.
E.g.
You could also take a look at the following very detailed forum topic, which covers similar scenarios. I hope that this was the information that you were looking for.
Dimiter Madjarov
Telerik
The standard approach for achieving this in an Ajax bounded grid is to bind to the edit event and check if the current model is new or edited. Since this event is not fired in the current scenario, you should parse the get parameters to check the current grid mode.
E.g.
$(document).ready(
function
() {
var
gridMode = getURLParameter(
"Grid-mode"
);
if
(gridMode ==
"edit"
) {
$(
"#GridPopUp"
).find(
'input[name="ProductName"]'
).attr(
"readonly"
,
true
);
}
});
function
getURLParameter(name) {
return
decodeURI(
(RegExp(name +
'='
+
'(.+?)(&|$)'
).exec(location.search) || [,
null
])[1]
);
}
You could also take a look at the following very detailed forum topic, which covers similar scenarios. I hope that this was the information that you were looking for.
Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gary
Top achievements
Rank 1
answered on 16 Sep 2013, 01:52 PM
Hello
The example below will not work as I am using the Grid in Server mode. Is there any way I can do this in Server mode?
Thanks
The example below will not work as I am using the Grid in Server mode. Is there any way I can do this in Server mode?
Thanks
0
Accepted
Hello Gary,
The sample code provided in my previous post is intended to work in a grid with server dataSource. Please test it on your side and let me know of the result.
Dimiter Madjarov
Telerik
The sample code provided in my previous post is intended to work in a grid with server dataSource. Please test it on your side and let me know of the result.
Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gary
Top achievements
Rank 1
answered on 16 Sep 2013, 08:25 PM
Thank you. It works as expected.
I have one more question: Is it possible to load those properties only once? i.e. on inital load.
I am running into an issue where the initialization code is run again when updating but those changes are lost because model validation fails.
I have one more question: Is it possible to load those properties only once? i.e. on inital load.
I am running into an issue where the initialization code is run again when updating but those changes are lost because model validation fails.
0
Hello Gary,
To achieve this you should implement some custom approach to store a boolean variable, which could be checked on page load and will serve as an indicator if the properties should be shown or not. Some sample approaches are storing a cookie or using local storage.
Dimiter Madjarov
Telerik
To achieve this you should implement some custom approach to store a boolean variable, which could be checked on page load and will serve as an indicator if the properties should be shown or not. Some sample approaches are storing a cookie or using local storage.
Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!