Extjs 6.5 Treestore not loading data from server - extjs

I'm migrating a small app from Extjs4 to 6.5. The problem is the treestore, which is very simple, but I cannot find out why the server routine is not called and also the exception-events are not called. I must overlook something, but I cannot find it.
The tree store is:
Ext.create("Ext.data.TreeStore", {
fields: ['mnu_Name'],
proxy: {
type: 'ajax',
headers: { "Content-Type": 'application/json' },
api: { read: '/Secure/WebServices/PageLayout.asmx/LoadMenuII' },
reader: {
type: 'json',
root: function (o) {
if (o.d) {
return o.d.data;
} else {
return o.children;
}
}
},
listeners: {
exception: function () {
alert('exception');
}
}
},
listeners: {
exception: function () {
alert('exception');
}
}
});
When I call the server routine with a plain Ajax call is works fine.
Ext.Ajax.request({
async: true,
url: '/Secure/WebServices/PageLayout.asmx/LoadMenuII',
headers: { 'Content-Type': 'application/json' },
success: function (response, options) {
//Extract data from the response
var data = Ext.decode(response && response.responseText || null, true);
//check op success=false
if (!data || data.success !== true) {
var errNumber = data && data.errNumber || 'Unknown',
errDescription = data && data.errDescription || 'Unknown';
Ext.Msg.alert("Warning", Ext.String.format(thisComp.errFormat, 'Warning in loading the menu definitione.', errNumber, errDescription), null, this, 9000)
return;
}
}
});
Any suggestion what I missed?
Thanks.
Arno

Related

AngularJS passing data to $http.get with parameters

i want to get data from the server while passing the parameters with my URL
the URL is 'http://localhost:30005/myapp/minMaxProduct/12'
And the data i want to pass is 12 with the get request.
my angularjs code is
getProductFromMinJWS: function(event) {
var config = {
params: {
maxMinVal: event
}
}
return $http.get('http://localhost:30005/myapp/minMaxProduct/',config);
},
the event is getting the value 12.but i get 404.can some one tell me the correct way to get data while passing parameters
Thanks
I have implemented like this
getProductFromMinJWS: function(url,data) {
var obj = {
url: url,
async: true,
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
};
if (typeof data != 'undefined' || data != null) {
obj.params = data;
}
return $http(obj);
}
I would do this:
getProductFromMinJWS: function(event) {
var ajaxConfig = {
url: "http://localhost:30005/myapp/minMaxProduct/" + event,
method: "GET"
}
return $http(config);
}
This is the corret way.

window.location.href doesn't work when using vue.js?

When I use angular.js, I use $.ajax in methods, then window.location.href when it succeeds. It works.
But when I use vue.js, it doesn't work until I add window.event.returnValue = false; after it.
I think it has nothing to do with angular.js or vue.js, because I use $.ajax, not $http or others. But why doesn't it work when I use vue.js?
$.ajax({
url: 'xxx',
type: 'post',
dataType: 'json',
async : false,
data: {
'xxx' : xxx
},
success: function (response) {
if (response.status == 'success') {
window.location.href = 'xxx';
// window.event.returnValue = false;
}
},
error: function () {
xxx
}
});
Please try this. It work perfectly for me.
created() {
this.vm = #Json.Serialize(Model)
this.ppp = window.location;
this.path = this.ppp.pathname;
this.lastid = this.path.lastIndexOf("/");
this.id = this.path.charAt((this.lastid + 1));
this.url = this.ppp.origin + '/Controller/Action/' + this.id;
console.log(this.url)
axios.get(this.url)
.then(response => { this.summary = response.data });
},
data:
{
vm: [],
summary:[],
ppp:'',
id:0,
url:'',
}
Hope this help

How do I upload Audio+video as one to server?

How to upload RecordRTC based audio+video recordings to server in a single file format?
RecordRTC seems generating two separate files: one for audio (as WAV) and another one for video (as WebM). How to upload both files simultaneously on a PHP server?
Since Chrome >=49, RecordRTC is now using MediaRecorder API to support microphone+webcam recordings into single WebM file format.
Here is how to record both audio+video into single WebM (this works both on Chrome >= 49 and Firefox >= 38)
<script src="https://cdn.WebRTC-Experiment.com/gumadapter.js"></scrip>
<script>
var recorder;
function successCallback(audioVideoStream) {
recorder = RecordRTC(audioVideoStream, {
type: 'video',
mimeType: 'video/webm',
bitsPerSecond: 512 * 8 * 1024
});
recorder.startRecording();
}
function errorCallback(error) {
// maybe another application is using the device
}
var mediaConstraints = {
video: true,
audio: true
};
navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
document.querySelector('#btn-stop-recording').onclick = function() {
if (!recorder) return;
recorder.stopRecording(function() {
var audioVideoBlob = recorder.blob;
// you can upload Blob to PHP/ASPNET server
uploadBlob(audioVideoBlob);
// you can even upload DataURL
recorder.getDataURL(function(dataURL) {
$.ajax({
type: 'POST',
url: '/save.php',
data: {
dataURL: dataURL
},
contentType: 'application/json; charset=utf-8',
success: function(msg) {
alert('Successfully uploaded.');
},
error: function(jqXHR, textStatus, errorMessage) {
alert('Error:' + JSON.stringify(errorMessage));
}
});
});
});
};
function uploadBlob(blob) {
var formData = new FormData();
formData.append('file', blob);
$.ajax({
url: "/save.php",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function(response) {
alert('Successfully uploaded.');
},
error: function(jqXHR, textStatus, errorMessage) {
alert('Error:' + JSON.stringify(errorMessage));
}
});
}
</script>
Here is an example save.php file that reads for video-filename and video-blob:
<?php
foreach(array('video', 'audio') as $type) {
if (isset($_FILES["${type}-blob"])) {
echo 'uploads/';
$fileName = $_POST["${type}-filename"];
$uploadDirectory = 'uploads/'.$fileName;
if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) {
echo(" problem moving uploaded file");
}
echo($fileName);
}
}
?>
Above save.php requires following FormData:
function uploadBlob(blob) {
var formData = new FormData();
formData.append('video-blob', blob);
formData.append('video-filename', 'FileName.webm');
$.ajax({
url: "/save.php",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function(response) {
alert('Successfully uploaded.');
},
error: function(jqXHR, textStatus, errorMessage) {
alert('Error:' + JSON.stringify(errorMessage));
}
});
}

Extjs Store Getting Data from Post

Good Morning,
I have a search endpoint that I that works when I call it like this:
Ext.Ajax.request({
url: '/Search/False',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
params: 'Attribute:ClosedDT;Value:2014-12-16',
success: function(conn, response, options, eOpts) {
alert(conn.responseText);
},
failure: function(conn, response, options, eOpts) {
alert(conn.responseText);
}
});
I want to use a proxy to load it into a store directly. After much googling I have tried this and i get back a POST /Search/False?_dc=1418738135737 net::ERR_EMPTY_RESPONSE
See current code below:
var proxyDefinition = {
type : 'rest',
api : {
read : '/Search/False'
},
actionMethods : {
read : 'POST'
},
reader : {
type : 'json'
},
paramsAsJson:true
};
returnValue = Ext.create('Ext.data.Store', {
model: 'Mdl1',
proxy: proxyDefinition
});
returnValue.load({params: 'Attribute:ClosedDT;Value:2014-12-16'});
The params config needs to be an object, not a string. Extjs will encode it for you because of paramsAsJson: true.
You should use:
params: {
Attribute: 'CloseDT',
Value: '204-12-16'
}

Move Ajax respose data to store in Sencha touch

how to add or save data that getting from ajax request to store or to model sencha touch 2
I have controller, store and a model. Ext.Ajax.request(); is called from controller and when it was successful I want move that data to store in json format
Ext.define('Myapp.controller.HomeController', {
extend: 'Ext.app.Controller',
config: {
control: {
"#homepage_id": {
show: 'onHomepage_idShow'
}
}
},
onHomepage_idShow: function (component, eOpts) {
var token = localStorage.getItem('Token'); //**************************************
console.log('test home', token);
var customHeaders = {
'Content-Type': 'application/json; charset=utf-8',
'ApiAuth': token
};
this.callAjax(customHeaders);
},
callAjax: function (headers) {
var customHeaders = headers;
Ext.Ajax.request({
url: 'http://localhost:9098/Folder/json/Get',
params: Ext.util.JSON.encode({
folderId: 0
}),
method: 'POST',
headers: customHeaders,
success: function (response) {
var decode_text = Ext.decode(response.responseText);
/*I want to add decode_text to a store from this contoller..*/
//var storez = Ext.data.StoreManager.lookup('commomStore_id');//****************
//this.getDataList().setStore(storez);
console.log(storez);
// process server response here
},
failure: function (response, opts) {
Ext.Msg.alert('Error', 'Error while submitting the form');
console.log(response.responseText);
},
scope: this
});
My Store:
Ext.define('Myapp.store.CommonStore', {
extend: 'Ext.data.Store',
requires: [
'Myapp.model.AuthTokenmodel'],
config: {
autoLoad: true,
model: 'Myapp.model.AuthTokenmodel',
storeId: 'commonStote_id',
proxy: {
type: 'localstorage',
id: 'commomStore_id',
reader: {
type: 'json'
}
},
fields: [{
name: 'authtoken'
}]
}
});
For that you have to parse your response and create Myapp.model.AuthTokenmodel objects out of it and then add those objects to your store using add method.
BTW if your response is in JSOn format you should parse it to JSON instead of text like this:
var respObj = Ext.JSON.decode(response.responseText);
console.log(respObj);
then create model objects using respObj data and add those to store:
var storez = Ext.data.StoreManager.lookup('commomStore_id');
storez.add(Ext.create('Myapp.model.AuthTokenmodel', {authtoken : respObj.authToken}));
Ext.getStore('commomStore_id').loadData(decode_text);

Resources