I have the following code:
<script>
function grid_errorHandler(e) {
console.log(e);
}
</script>
#(Html.Kendo().Grid(Model)
.Name("ResultsGrid")
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("grid_errorHandler"))
However when the ajax call fails (due to invalid credentials), I dont get any logs, is there any way I can catch an error on the ajax request for the kendo ui grid?
Try
function grid_errorHandler(e) {
console.log(e.status);
}
Hope this helps, you can find more info here.
Related
I have an issue on having an external template inside Column ClientTemplate
.Columns(col =>
{
col.Bound(c => c.ID);
col.Bound(c => c.Name).Width(100);
col.Bound(c => c.StatusID)
.Title("Action")
.ClientTemplate("#=_actionTemplate(data)#")
.Width(100);
})
<script id="tmplAction" type="text/x-kendo-template">
#(Html.Kendo().Button().Name("btnTest_#=ID#")
.Content("Test")
.ToClientTemplate())
</script>
<script>
var _actionTemplate = kendo.template($('#tmplAction').html());
</script>
Even though it is called and rendered inside the grid column, kendo script is not executed therefore the only rendered element is a basic Button and not Kendo Button
Any help would be appreciated
Copied from your code :
.ClientTemplate("#= fnactionTemplate(data)#")
And declare that function like:
function fnactionTemplate(data){
// External logic goes here....
return $('#tmplAction').html();
}
Hope it will work.
I'm doing a website based laravel 4.2 and Bootstrap. I want a bootstrap modal pop up dialog to load on certain routes provided that the user is not already logged in.
So far i have accomplsihed it to load for the entire application upon loading which is not i want but am in the right direction.
This is my ajax call
script type="text/javascript"> $(document).ready(function() {
$.get("status", function(data, status){
data.status == false ? $('#modal-form').modal({backdrop: 'static'}) : $('#modal-form').modal('hide');
});
});
Status refers to a URL defined in this route
Route::get('/status', 'LoginController#getLoginStatus');
and the method is defined here
public function getLoginStatus()
{
return Response::json(array( 'status' => Sentry::check()));
}
From that, the modal dialog loads on each route across the entire application. I would want to limit the dialog to load on certain routes provided the user is not logged in.
Thing Laravel filter would do the trick for me but i have failed to do so.
Something like
Route::filter('status', function()
{
});
and then the route be like:
Route::get('profile', array('as' => 'submit-profile','before' => 'status','uses' => 'ProfileController#getProfile'));
Thanks guys hope you can give me some advice.
You could use the
Route::currentRouteName()
to check what route your on and then do your preferred action,
like calling the ajax get request for the modal.
I've got a Kendo Ui datetimepicker. But when I choose time or date, there is an error "Cannot call method 'attr' of undefined", that appears in kendo.all.min.js. What might be the issue?
Honestly, i've got Kendo Scheduler. But when i try to create an event, there are datetimepickers, and when i choose date or time i've got such kind of error.
Here's my code:
#{
var culture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
}
<script src="#Url.Content("~/Scripts/kendo/jquery.min.js")"></script>
<script src="#Url.Content("~/Scripts/kendo/kendo.all.min.js")"></script>
<script src="#Url.Content("~/Scripts/kendo/kendo.aspnetmvc.min.js")"></script>
<script src="#Url.Content("~/Scripts/kendo/cultures/kendo.culture." + culture + ".min.js")"></script>
<script>
kendo.culture("#culture");
</script>
#using Kendo.Mvc.UI
#(Html.Kendo().Scheduler<TaskViewModel>()
.Name("scheduler")
.Date(DateTime.UtcNow)
.StartTime(DateTime.UtcNow)
.Height(600)
.Width(1000)
.Timezone("Etc/UTC")
.Views(views =>
{
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
views.AgendaView();
})
.DataSource(d => d
.Model(m => {
m.Id(f => f.TaskID);
})
.Read("Read", "TaskManager")
.Create("Create", "TaskManager")
.Destroy("Destroy", "TaskManager")
.Update("Update", "TaskManager")
)
)
i'm using ru-Ru culture.
Does your declaration/include of scripts looks something like this:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
...
JQuery should be declared first and along with your Kendo scripts.
The second posible cause is your JQuery selector. Try something simple and setting both name and id attributes like:
$("#ctrl")
As per the requirement, I am having a Kendo UI grid on my VIEW.But sadlyy, the read function is not being hit in the controller.This is annoying ,I am getting the same problem even though everyhting seems to be as per the documentation provided on http://demos.kendoui.com/web/grid/index.html. Here is my View code:
#(Html.Kendo().Grid<StudentManagement_Models.Student>()
.Name("studentsGrid")
.Columns(columns =>
{
columns.Bound(p => p.Id).Groupable(false);
columns.Bound(p => p.FirstName);
columns.Bound(p => p.MiddleName);
columns.Bound(p => p.LastName);
columns.Bound(p => p.CGPA);
})
.AutoBind(true)
.Pageable()
.Navigatable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetAllStudents", "Student"))
)
)
Here is my controller action:
public ActionResult GetAllStudents([DataSourceRequest] DataSourceRequest request)
{
//Thread.Sleep(2000);
StudentManagement_Models.Student student = new StudentManagement_Models.Student();
StudentHelper helper = new StudentHelper();
student.SavedStudents = helper.GetAllStudents();
return Json(student.SavedStudents.ToDataSourceResult(request));
}
How would I tackle this ?Am I missing something ?Kindly suggest.
Thanks in advance.
Add all of this file in your page
<script src="~/Script/Jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="~/Script/jquery-ui-1.8.20.min.js" type="text/javascript"></script>
<script src="#Url.Content("~/Script/kendo.all.min.js")" type="text/javascript"></script>
<script src="~/Script/kendo.web.min.js" type="text/javascript"></script>
<script src="~/Script/kendo.aspnetmvc.min.js" type="text/javascript"></script>
<link href="~/Content/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/kendo.default.min.css" rel="stylesheet" type="text/css" />
I think you mis one of the js in your page , probebly Jquery-1.8.1.min.js .
I was having similar issue with the MVC version.
I noticed I was getting a 404 but when clicking the 404'd link in the Chrome debugger it would indeed hit my controller method. Then I noticed that it was using POST (and I had HttpVerbs.Get) specified.
Then I found this (from http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/troubleshooting):
By default Kendo Grid for ASP.NET MVC should make POST requests when
configured for ajax binding. This is implemented by a custom
DataSource transport and schema. Those are defined in the
kendo.aspnetmvc.min.js. Make sure that this file is included after the
other Kendo JavaScript files.
After verifying that the scripts were indeed in the correct order (and knowing it probably had something to with POST) I specified the verb to use at the end of my Read in the grid as so:
.Read(read => read.Action("MyList_Read", "Diagnosis").Type(HttpVerbs.Get))
This solved MY problem.
try to call the read method with JQuery's document.ready()
$(document).ready(function ()
{
var grid = $("#studentsGrid").data("kendoGrid")
grid.dataSource.read()
})
Also is savedStudent a type of student.... Ur grid is bound to Student but you are returning SavedStudent objects
"By default Kendo Grid for ASP.NET MVC should make POST requests when configured for ajax binding. " ???
For Kendo UI version 2014.1.318, I think, by default Kendo Grid for asp.net mvc makes GET requests when configured for ajax binding.
I discovered that if there are two grids on the same webpage (in this case, in different tabs), then each grid MUST have its own datasource method in the MVC controller - even if both grids are using the same data,
I am using cakephp and pippoacl plugin and I simply cannot add a new role. What I modify in the plugin is to make the submit using ajax, something like this in my view (add.ctp):
<?php echo $ajax->submit(
'submit',
array(
'url' => array('controller' => 'roles', 'action' => 'add'),
'before' => 'beforeSubmitAdd();',
'complete' => 'completeSubmitAdd(request);'
)
);
?>
When the add.ctp gets loaded for the first time, I can print_r something from the controller. But the ajax submit above only executes the javascript on 'before' and 'complete'. I check on the firebug, the response is blank.
On my controller:
function add() {
print_r("start");
if (!empty($this->data)) {
print_r("add new role");
// save new role
}
}
I use ajax submit for user and I don't have any problem adding new user. Is there any idea where I should check? I have been comparing the user and role code for a week and I have asked a friend to look at my code, too, but we still cannot find what causes this.
Thanks in advance! :D
I am not so familiar with the Ajax helper, but I haven't using it from so long that I can't remember what is it doing :).
Back to the problem.
Did you check if the requested URL in the Ajax address is correct? This should work straightforward, but it's possible that the url to be invalid.
Are you using Security component (even just adding it on the var $components variable)?. This could lead to blank screen especially if you modifying the fields in the form somehow. Try to remove it and see if it's working without.
Finally I would say how I would do it with jQuery.
Following code should do the job:
$(document).ready(function(){
$('form').live('submit', function(){ //handles also dynamically loaded forms
var form = $(this).addClass('loading'); //indicate somehow that the form has been submitted
$('#content').load($(this).attr('action'), $(this).serialize(), function(){
form.removeClass('loading');
});
})
});
This will handle all submits in the forms of the system, but you can modify of course.