kendo UI file manager navigation issue - javascript

HTML code:
<div id="filemanager"></div>
javascript code:
$(document).ready(function () {
$("#filemanager").kendoFileManager({
dataSource: {
transport: {
read: function (options) {
$.ajax({
method: "GET",
datatype: "json",
url: Djangourl,
success: function (result) {
console.log(result);
options.success(result);
},
error: function (result) {
options.error(result);
}
});
},
}
}
});
}
JSON returned by server:
[
{
"name": "abc",
"isDirectory": true,
"hasDirectories": true,
"path": "folder",
"extension": "",
"size": 0,
"created": "2022-07-06T11:28:46.932Z",
"createdUtc": "2022-07-06T11:28:46.932Z",
"items": [
{
"name": "abc_123",
"isDirectory": true,
"hasDirectories": true,
"path": "folder/abc_123",
"extension": "",
"size": 0,
"created": "",
"createdUtc": ""
}
],
"modified": null,
"modifiedUtc": null
}
]
Issue: folder 'abc' is displayed but item inside is not getting displayed, on double click on abc again ,ajax is calling the url. I want to display 'abc_123' directory on double click of 'abc' folder as shown in 'https://dojo.telerik.com/UpUgeZOH' example.

Related

How to pass an array value to Router.navTo in SAPUI5

I have this call in a SAPUI5 code. Before the soldTo was a simple comboBox, but I changed it for a multiComboBox. So, now this.soldTo is an array.
this._oRouter.navTo("SearchResult", {
soldTo: this.soldTo,
shipTo: this.shipTo,
}, false);
The routing in manifest.json is defined like this:
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "com.openOrder.AM.view",
"controlAggregation": "pages",
"controlId": "app",
"clearControlAggregation": false
},
"routes": [
{
"name": "RouteApp",
"pattern": "",
"target": [
"Search"
]
},
{
"pattern": "{soldTo}/{shipTo}/SearchResult",
"name": "SearchResult",
"target": [
"SearchResult"
]
},
{
"name": "ResultDetails",
"pattern": "{}/ResultDetails",
"target": [
"ResultDetails"
]
}
],
"targets": {
"Search": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewName": "Search",
"viewLevel": 1
},
"SearchResult": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewName": "SearchResult",
"viewLevel": 2
},
"ResultDetails": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewName": "ResultDetails",
"viewLevel": 3
}
}
}
I'm getting this error after change.
"Uncaught TypeError: Cannot read properties of null (reading 'length')"
Does anyone has an exemple how to pass the multiComboBox values to the function Router.navTo, please?
There is no need to send the array with a URL. The URL makes only sense if you want a unique address for a specific record. Therefore you should pass it with the model on your component.
Define your model in the manifest. The definition will enable you to access it using "this.getModel(""). In your views you can access the model with "this.getOwnerComponent().getModel("").

Is it possible to load, then select a child node if the parent node is unknown to the tree?

I am using jsTree as a navigator for the user to select different items which display in another pane. So far everything is working as expected except if the user (from the other pane) selects an item that hasn't been loaded into the tree yet.
The Tree is currently getting all of its data from AJAX.
I have tried using the open_node() and load_node() functions but they have no effect if the parent node is not loaded.
My question: is it possible to load, then select a child node if the parent node is unknown to the tree? If not, are there any workarounds to achieve a similar effect?
EDIT:
Tree initializer:
$('#jsTree-Location').jstree({
"core": {
"animation": 0,
"check_callback": true,
"themes": {
"stripes": true,
"icons": true
},
"data": {
'url': '#Url.Action("LocationList", "Location")',
'type': 'GET',
'dataType': 'JSON',
'contentType': 'application/json',
'data': function (node) {
return { sID: node.id, sType: node.type };
}
}
},
"json_data": {},
"plugins": [
"contextmenu", "dnd", "search",
"state", "wholerow", "types"
],
"state": { "key": "system" },
"contextmenu": { items: customMenu },
"types": {
"default": {
"icon": "glyphicon glyphicon-flash"
},
"location": {
"icon": "fas fa-map-marker-alt"
},
"asset": {
"icon": "fa fa-cube"
},
"link": {
"icon": "fa fa-cube"
},
"system": {
"icon": "fas fa-cogs"
}
}
}})
Function called when user 'externally' selects a node
function DisplayAsset(id) {
ShowSpinner($("#window"), "Loading Asset...");
//If Location Tree is active, activate the Asset in it.
var sysTree = $('#jsTree-Location').jstree().get_selected()[0]
if (typeof sysTree !== "undefined") {
$("#jsTree-Location").jstree().open_node(['#asset-' + id, '#link-' + id], function (node, status) {
if (status) {
$("#jsTree-Location").jstree().activate_node(node)
}
})
}
//AJAX call to get Asset partial display
$.ajax({
url: '/Assets/_AssetEdit/',
type: 'GET',
data: {
'id': id
},
success: function (html) {
HideSpinner($("#window"));
$("#window").html(html)
BuildTable();
}
})
}

How to retrieve user details in follow button callback function in twitter api?

I have tried to retrieve logged in user name and location details in follow button callback function.
twttr.ready(function (twttr) {
twttr.events.bind('follow', function (event) {
$.ajax({
type: "GET",
dataType: "json",
url: "https://api.twitter.com/1.1/users/show.json?user_id=" + event.data.user_id,
success: function (data) {
console.log(data);
}
});
});
});
But I couldn't able to retrieve user details. Is it possible to retrieve user details?
Looks like show already include user detail https://dev.twitter.com/rest/reference/get/users/show
Example Result:
{
"contributors_enabled": false,
"created_at": "Sat Dec 14 04:35:55 +0000 2013",
"default_profile": false,
"default_profile_image": false,
"description": "Developer and Platform Relations #Twitter. We are developer advocates. We can't answer all your questions, but we listen to all of them!",
"entities": {
"description": {
"urls": []
},
"url": {
"urls": [
{
"display_url": "dev.twitter.com",
"expanded_url": "https://dev.twitter.com/",
"indices": [
0,
23
],
"url": "https://t.co/66w26cua1O"
}
]
}
},
"favourites_count": 757,
"follow_request_sent": false,
"followers_count": 143916,
"following": false,
"friends_count": 1484,
"geo_enabled": true,
"id": 2244994945,
"id_str": "2244994945",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 516,
"location": "Internet",
"name": "TwitterDev",
"notifications": false,
"profile_background_color": "FFFFFF",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",

ajax in jquery error : converting circular structure to JSON

I console JSON.stringify(stateArr) my json look fine and look like this
{
"shipping_options": [{
"id": "1",
"name": "Kuala Lumpur",
"rate": "222"
}, {
"id": "2",
"name": "Labuan",
"rate": "1"
}]
}
but I got converting circular structure to JSON error with my below code, I wonder why?
param["state"] = stateArr;
$.ajax({
type: "POST",
url: 'example.com',
data: {
type: "json",
data: JSON.stringify(param)
},
cache: false,
async: false,
timeout: 10000,
success: function(data) {
alert('ok');
},
error: function(response) {}
});
I think you have something like
var param = stateArr;
param["state"] = stateArr;
This is a circular structure. Check your param reference.

parse facebook json javascript

I am using javascript api to get facebook comments.
i am getting the following json result , but how can i parse them to use on my page ?
{
"id": "1234567891_2823098717038_3160191",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "comment only...",
"can_remove": true,
"created_time": "2012-05-05T07:43:11+0000"
},
{
"id": "1234567891_2823098717038_3160281",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "just another comment...",
"can_remove": true,
"created_time": "2012-05-05T08:14:17+0000"
},
{
"id": "1234567891_2823098717038_3160336",
"from": {
"name": "user2",
"id": "56265654845454"
},
"message": "congratz dear :)",
"can_remove": true,
"created_time": "2012-05-05T08:29:05+0000"
}
],
"paging": {
"next": "http://link.dddd"
}
}
How can i loop through this and display the contents ?
jQuery solution is acceptable.
Thank you.
Use JQuery.parseJSON: http://api.jquery.com/jQuery.parseJSON/
assoc_data = jQuery.param(response); //where response is your json
$.ajax({
type: "POST",
url: "submit_fb_data.php",
data: assoc_data,
success: function(data) {
//etc
}
});
make sure you use a >=1.4 jquery version

Categories