I'm new in Kendo UI & Codeigniter. I have trouble with Kendo UI when i trying to read data from codeigniter controller.
I can see json data, which is return from controller, but it not display at Kendo UI grid. Below is some screen shoot when i'm debug.
Here is screen shot error
http://prntscr.com/5bmn3n
Here is screen shot data i recived
http://prntscr.com/5bmne5
Here is screen shot Kendo UI code:
prntscr.com/5bmnib
And here is screen shot my controller code:
prntscr.com/5bmnni
Hope you can help
Please, try to add
transport: {
read: {
...
dataType: "json"
...
}
},
Also, please have in mind that "jsonp" is required for cross-domain requests!
Related
In a SAPUI5 controller of a master view I trigger a oModel.read() request to read some data (async). This read will be done each time the page will be reached during navigation.
onInit: function() {
var that = this;
this.getRouter().getRoute("PageName").attachMatched(this.onRouteMatched, this);
},
onRouteMatched : function(oEvent) {
...
oModel.read(....); // this will be done async
...
},
The app should be normal rendered (with normal binding).
The mentioned read will load some messages from the server and syncs it with a local model. Now in case of a new message a dialog should be shown.
Here is my problem: Where to place the dialog.open() call in the controller (what event?) so that the dialog will be shown?
Right now I tried with onAfterRendering and there it works for exactly the first call. For further calls I can't see any dialog. If I place the open dialog in the onRouteMatched I can see a short flickering.
So the problem is, that opening the dialog should be done after the rest of the application is rendered. But how to reach this?
Meanwhile I have a hacked solution.
In the onInit method of the controller I register to the onmousemove event. Each time the mouse will be moved I can check if there is some data to show.
this.getView().attachBrowserEvent("mousemove", function(oEvent) {
this.onCheckForMessages();
});
But better solutions are welcome.
I have a modal form (using bootstrap) that I use to add a user. This form is wired to a 'addUser' method via RequestMapping in my Controller. Adding a user works fine.
Is there a simple way I can populate the same modal form to edit existing user details after clicking an edit button? Do I have to make an AJAX call to a REST endpoint to populate the form, or is there a better way of doing this?
I'm using Spring Boot.
Thanks,
Jerry
An AJAX request would be your best bet, otherwise you'd have to load all the editable user properties ahead of time when you load the page of existing users and store them in memory or on the page somehow. It's not the most efficient solution though because you're loading all those properties for all users, every time you reload the page. If you only have a handful of users, that might be ok for you, but if you're dealing with a large set of users, then that will make for longer request times.
Yes you can make a ajax request and get the modal details in form of Json or Xml.
Below example retrieve the user details and set it into modal form variables like userName
$.ajax({
type: "post",
url: "Url to get the response",
cache: false,
data:'userId=' + $("#userId").val(),
success: function(response){
var obj = JSON.parse(response);
$('#userName').val(obj.userName);
},
error: function(){
alert('Error while request..');
}
});
I am working on ASP.Net MVC 3 website which uses Razor view engine and Jquery
On homepage (or any page for that matter) I want to load sections of content using ajax, something like iGoogle.
I mean on page load
I want to call some HttpGet action methods each of which returns some
Html content
Until I get response these Div's showing "loading" graphics.
I am aware of Ajax.BeginForm and Ajax.ActionLink but in both the cases I need to click some UI element; I do not know how to use them on page load/ document.Ready?
I will be thankful even if I get some direction and not exact/complete code.
Okay, lets give you some direction, I'm going to show some code in jquery because its easy enough. lets go.
Html
<div id="SomeContent"> </div>
In your view
$(function(){ // this runs on on page load
LoadData('#SomeContent', #Url.Action("ActionName","ControllerName"));
});
in a javascript library file
function LoadData(target, url){
$.ajax({
beforeSend: startAnimation(target),
url : url,
success : function(result){ $(target).html(result); },
complete : stopAnimation(target)
});
}
function startAnimation(target){
//..add a loading image on top of the target
}
function stopAnimation(target){
// remove the animation gif or stop the spinning, etc.
}
your server side code
public ActionResult ActionName() {
... do things to get your model populated ...
return PartialView("SomeView", yourmodel);
}
additional thoughts:
this rough code loads a partial view into a div. The asychonous call begins when the dom is ready.
see http://api.jquery.com/jQuery.ajax/ for jquery ajax documentation
i like to use spin.js to show a loading icon becuase it is so darn easy and small.
I have my jquery mobile app pulling data from our mysql db using JSONP. The data is pulling fine, but the problem comes when I go back to the previous "page" in my app then click on a different option, it doubles the data on the next screen, and it will just keep stacking the data as many times as I do that. What am I missing?
The app doesn't look right in any browsers, but it looks fine in the ios simulator or appmobi simulator. I can post some code if needed, just know it won't look right in your browser.
Thank you for any help you can provide
$('#two').bind('pagecreate',function(event){
var img = getUrlVars()["st"];
var photo = $('#img');
$.ajax({
type: 'GET',
url: 'http://serverhidden/json/img.php?st='+img,
dataType: 'jsonp',
success: function(data) {
$.each(data, function(i,item){
var image = '<img class="stmap" src="images/states/lrg/'+item.img+' "/>';
photo.html(image);
});
},
error: function(e) {
//called if there is an error
//console.log(e.message);
}
});
});
Make sure you are not subscribing your event multiple times. It seems silly but is easy to do.
I would recommend you add logs to your JQM site so that you can see how many times your site is being updated.
You should also be aware that updating a JQMobile page often requires a call to a method to update content after a page is rendered. See here: jQuery Mobile rendering problems with content being added after the page is initialized
Hope those help.
So without any code from your project this is a shot in the dark but it seems like you populate a pseudo-page with information on pageshow with an .append() call. Instead of using .append(), use .html() as it will replace the information already present rather than add to it.
If each state has an individual page then you can bind to the pagecreate (or similar) event so the data will only be appended once rather than on each pageshow event.
using jquery ui tabs, when you load a tab in ajax, the tab changes message to say "Loading . ." i think this is a little subtle.
Is there anyway you can do something in this content area of the tab similar to what block ui does when you are loading a call in ajax.
You would display a loading message within the content area like so (untested):
$('#selector').bind('tabsselect', function(event, ui) {
// show default $.blockUI loading message
$('ui.panel').blockUI();
}).bind('tabsload', function(event, ui) {
// remove loading message
$('ui.panel').unblockUI();
});