kendo ui scheduler widget doesnt load my events - kendo-ui

I'm attempting to use the new Kendo Scheduler widget. I have server code generating text/jsonp using PHP for two events but they dont show. Firebug shows me this as the response :-
[{"TaskID":"599","Title":"Test Al's Birthday","Description":"Als birthday bash","Start":"2014-07-16 04:00:00","End":"2014-07-18 04:00:00","RecurrenceID":null,"RecurrenceRule":null,"RecurrenceException":null,"StartTimeZone":null,"EndTimeZone":null,"IsAllDay":"false"},{"TaskID":"598","Title":"test dave bday","Description":"Daves birthday bash","Start":"2014-07-16 04:00:00","End":"2014-07-17 04:00:00","RecurrenceID":null,"RecurrenceRule":null,"RecurrenceException":null,"StartTimeZone":null,"EndTimeZone":null,"IsAllDay":"false"}]
I should have mentioned I used the 'Basic Usage' example and only changed the URL for the read to be my php script. Everything else is the same.
What am I missing, is it the date formats ?
I'm using mysql and my select is:
select p.id as TaskID, p.name as Title, p.Description, date_format(p.project_start,GET_FORMAT(DATETIME,'ISO')) as Start, date_format(p.project_end,GET_FORMAT(DATETIME,'ISO')) as End, null as 'RecurrenceID', null as 'RecurrenceRule', null as 'RecurrenceException', null as 'StartTimeZone', null as 'EndTimeZone', 'false' as 'IsAllDay'
I jsut can't see what could be wrong ??

You response looks like JSON and not JSONP. This is one of the things which may be broken. Try setting the dataType of your transport.read option to "json" instead of "jsonp":
dataSource: {
transport: {
read: {
url: "tasks.php",
dataType: "json"
}
}
}
Other than that the response looks OK. The date format is supported. I created a live demo using local data in the same format as yours: http://jsbin.com/oyIf/2/edit

The answer is that in the example there's a field OwnerID and I didn't have that so left it out. I didn't notice that the filter uses it and so stopped it working..

Related

error 404 while using {{url()}} on laravel ajax

Greating,
I have some error while using ajax on laravel, the console return 404,
that's my ajax
$('#btn_search_postcode').click(function(e){
let postcode = $('#postcode').val();
if(postcode != ""){
$.ajax({
method: "GET",
url: "{{route('company.postcode')}}",
dataType: "JSON",
data:{
'id':postcode
},
success: function(result){
if(result != ""){
console.log(result.prefectureid);
}
else{
console.log('null');
}
}
})
}
})
I have change the url to "{{url('company/postcode')}}/"+postcode but still error
that's my route
Route::GET('/company/postcode/{id}', 'mycontroller\companyController#getPostCode')->name('company.postcode');
but the code working fine when I change the url into
url: "http://localhost/mylaravel/public/company/postcode/"+postcode,
I can't use the last method because in other pc using different port.
can anybody help me for this issue?
note : i can see the csrf token, when i add the csrf token again in ajax, I see 2 token on error link
EDIT:
I still not resolve that, but now im using url:rootUrl+"/companies/postcode/"+postcode, to resolve that issue, is it ok to do like that?
The problem is that your route has a required parameter {id} and since you don't provide it when you render the url of the route, laravel doesn't find the route.
Two solutions:
make the id parameter optional in your route declaration like so Route::GET('/company/postcode/{id?}', 'mycontroller\companyController#getPostCode')->name('company.postcode'); (note the {id?})
provide the parameters trough php with some defined variable in the view ex: {{route('company.postcode',$id)}}
Cordially
you have to change it like these
url: "{{url('company/postcode')}}"+'/'+postcode
please try these and let me know what happened
If I understand what you are asking, you have a route that is named company.postcode, is that correct? If you do have that route, and now what you are wanting is to get the company by postcode, you will need to take advantage of Laravel's Route Model Binding. What you can do is go into your model and create a function like this:
public function getRouteKeyName()
{
return 'postcode';
}
Yet, I see an issue with that that can cause you some issues down the road. What happens when you have multiple companies with the same postcode? How will Laravel know which one you want?
A much better option is going to be to use the id field and retrieve your company with it. Unless you make the postalcode field in the database a unique field. Which again raises the question of what happens when you have two or more companies wanting access to your website that share the same postal code?

ASP.NET Core API POST parameter is always null from Firefox

In my Angular2 Application, I'm submitting a form and send data through POST API to dotnet core backend. I've created a new form, that is working fine with chrome, but on firefox, I'm receiving null in POST API parameter.
I'm all stuck what to search and how to?? I've checked every possible issue and didn't find anything, because App is working fine with chrome, all data is up to date and correct but a single form is not working on firefox.
Can anyone help me out what to do? because I'm totally stuck and have
no idea what to do??
My Endpoints are;
[HttpPost]
[Route("api/Intimation/SaveIntimation")]
public async Task<ActionResult> SaveIntimation([FromBody] ViewModelCreateIntimation objCreateIntimation)
{
if (objCreateIntimation == null || objCreateIntimation.objIntimation == null)
{
return Ok("null received");
}
// remaining code
}
my service on angular side
saveIntimation(intiModel) {
console.log(intiModel);
return this.httpClient.post<ViewModelResponse>(this.baseUrl + this._SubmitIntimationUrl, JSON.stringify(intiModel), { headers: this.configurations.getHeaderWithAuth() });
}
where this._SubmitIntimationUrl is "/api/Intimation/SaveIntimation", intiModel is object that I'm passing.
Controller function - Angular
this.intimationModel = this.admissionForm.value;
this.adminService.SubmitAdmissionIntimationService(this.createIntimationModel).subscribe(
(response) => {
this.responseModel = response;
// further process
},
(error) => {
this.notification.onClear();
this.notification.onError(this.errorHandler.handleError(error).error, Constants.MESSAGE_ERROR);
}
);
Data that is sending from service (Last place where I can check data)
The problem looks like it's because of the name of the parameter in your controller is different to that being passed up in the request.
In your controller, the parameter the framework is trying to bind to is called objCreateIntimation, but your request shows you're sending up objIntimation instead. As they have different names, the model binder has no idea that objIntimation should be bound to objCreateIntimation.
Give them both the same name, and that should fix it for you.
I went through same issue once, and It took almost a day to figure out the reason behind it,
do check your date pickers and its values, and make sure it is not null and its format is also correct. Because firefox is a bit strict in this matter and a litter change in datepicker makes it null.
hope it helps you.

Post Data Getting Lost during Ajax Post Request in Razor

I am working on an ASP.net MVC 3.0 Application with razor view engine.
I am making an ajax post as follows:
$.ajax({
type: "post", contentType: "application/json;charset=utf-8",
url: GetErrorCountUrl,
success: function (data) {
});
Here, the URL is as follows:
var GetErrorCountUrl = '#Url.Action("GetErrorCount", "WError", new { Id= "Token", id1 = "Token1", id2= "Token2" })';
GetErrorCountUrl = GetErrorCountUrl.replace('Token',pkid).replace('Token1',cid).replace('Token2',itemclass);
I am building the correct URL . I checked by using alert(url). It is hitting that controller action.
In my controller action,
If i do : Request.params["Id"] --> I was getting the correct value
Reuqest.params["id1"] --> I am getting null values
but, when i do:
reuqest.Params[0] --> correct value
request.params[1] ---> Correct value
I was getting correct values when using index instead of name.
I need get those values based on Parameter name not on index.
Please help.
Except for the first parameter..i was not able to get the values of other parameters
First of all the name of variabeles should start with low letter in JavaScript. Names with the first capital variable should be used only for classes (functions used in constructors). Prettify formatting of the code used on stackoverflow uses other colors for JavaScript classes. For example to define data in JavaScript one should use var d = new Date(); instead of var d = new Date();. So the code like var GetErrorCountUrl = "some string"; looks in JavaScript very strange. I understand that JavaScript is not your main language, but it's really better the name conversion used in the language which one uses.
Now back to your main question. It seems to me that
GetErrorCountUrl.replace('Token',pkid).replace('Token1',cid).replace('Token2',itemclass);
Isn't what you really want. If the string GetErrorCountUrl contains 'Token1' then the 'Token' part of the substring 'Token1' will be first replaced to pkid and the next replacement (to cid) will never work.
To fix the problem you can change the order or replacements to the following for example:
GetErrorCountUrl.replace('Token1',cid)
.replace('Token2',itemclass)
.replace('Token',pkid);

jQGrid pagination and OData

My problem lies with jQGrid and an OData data source (.NET WCF)
I am attempting to get jQgrid paging to work correctly, currently I have a basic data load and column sorting functioning.
I did this by overriding the xmlReader function to get jQgrid to parse the OData XML
xmlReader: {
root: "feed",
row: "entry",
id: "entry>id",
total: "m:count"
}
Then on the request to the server I overrode the serializeGridData function to attempt to send the requst in OData format.
serializeGridData: function (obj) {
obj["$inlinecount"] = "allpages";
obj["$orderby"] = obj.sidx + " " + obj.sord;
obj["$skip"] = (obj.page - 1) * obj.rows;
return obj;
}
But the problem is the OData response only contains the m:count which is the total number of records. I believe jQGrid needs at least totalrecords, currentpagenum, and totalPages to get the pagination to work correctly.
What am I missing?
A side question is how does Kendo UI Grid accomplish this and is there anything I can learn (or lift) from their code??
Server Side Paging Demo - http://demos.kendoui.com/web/grid/remote-data.html
Where the demo communicates with an oData source: http://demos.kendoui.com/service/Northwind.svc/Orders
Using the same oData format and getting the same response - lacking page number.
If you'd like... I've gotten it working for a project I'm on, and I have a gist up that you can peruse...
https://gist.github.com/dealproc/6678280
First of all I recommend you to use JSON instead of XML to communicate with OData WCF service. If you use ASP.NET 4.X then you will need just include automaticFormatSelectionEnabled="true" attribute in settings of the endpoint of WCF service. See the answer for more details. After that you can just use datatype: "json" and ajaxGridOptions: { contentType: "application/json" } options of jqGrid. The OData WCF service will returns JSON data.
The example of serializeGridData, jsonReader and prmNames you will the answer. I think that you can just use the options in your case too.

Issue with creating Facebook events through Graph API. I get an ID, but it's not created

So, I'm using the Graph API with the Javascript SDK to create an event. It works fine and I get the ID like I'm supposed to from a successful event creation. However, when I go to look at the event or find it in the graph explorer, it's like it hasn't been created.
Here's my code:
function createEvent(name, start, end, location) {
start = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours());
end = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate(), end.getHours());
FB.api('me/events', 'post', { name: name, start_time: start, end_time: end, location: location }, function (response) {
console.log(response);
});
}
I have no idea what's wrong with it and why the event would appear to not have been created.
I have found that if the start_time is not formatted to ISO time format, FB will give you back and EventID but not create the Event.. Try to use the Graph API explorer to do a Post, add parameters name and start_time then grab and time formatted string from another Graph API result, it should work
-John Gentilin

Resources