How to manage the contextmenu of jsTree as per the file and folder - contextmenu

I have stuck to manage the contextmenu after the right click . Actually I need to display some item of contextmenu for folder and some item of contextmenu for folder.
On click of folder context menu will look like :
create
remove
rename
new
On click of file context menu will look like :
create
remove
rename
Is there any way to manage this menu after click . I have look into documentation and other blog , but not getting useful content .
Can you please guide me some thing so that I can implement like that .
Thanks in advance

Hello ,
Thanks for take a look, but I got the way to make it Please take a look on below :
$('#detail_dir_container').jstree({
"json_data" : {
"ajax" : {
"url" : ''
}
},
"contextmenu" : {
"items": function(node){
if(node.attr('type') == 'file' )
{
return {
create : true,
rename : true,
remove : true
}
}
else
{
return {
create : true,
rename : true,
remove : true,
new : true,
}
}
}
});
Thanks

Related

Failed to add saved page to menu bar - wrapper application using electron

I recently follow a project electron on geeksforgeeks: https://www.geeksforgeeks.org/create-a-geeksforgeeks-wrapper-application-using-electron/
Here is its code on Github https://github.com/sayantanm19/geeksforgeeks-desktop/blob/master/index.js
The function appenItemToMenu doesn't work, which means I could save pages offline but the savedpagelist on menu bar is always empty ...
Could you try it on your machine and point out the bug?
function appendItemToMenu(filename) {
curr_menu = Menu.getApplicationMenu()
.getMenuItemById("saved").submenu
curr_menu.append(
new MenuItem({
label: path.basename(filename, '.html'),
click() {
console.log('Saved page opened')
win.loadFile(savedFolder + path.basename(filename))
}
}))
}
function appendItemToMenu(filename) {
const newMenu = Menu.getApplicationMenu()
curr_menu = newMenu.getMenuItemById('saved').submenu
curr_menu.append(
new MenuItem({
label: path.basename(filename, '.html'),
click() {
console.log('Saved page opened')
win.loadFile(savedFolder + path.basename(filename))
}
}))
Menu.setApplicationMenu(newMenu)
}
Update the application menu after change. Any dynamic change or append Item not allowed.

How to navigate from one page to another in Ionic?

Need some help implementing a redirect to a certain page in Ionic. I have tried the following code samples, but none of them work for me:
this.navCtrl.setRoot(this.flightdetailsPage);
//this.router.navigateByUrl('/flightdetails');
//this.navCtrl.push('flightdetails');
// this.navCtrl.navigateForward("flightdetails");
//this.router.navigate(['flightdetails']);
this.navCtrl.setRoot(this.flightdetailsPage);
//this.router.navigateByUrl('/flightdetails');
//this.navCtrl.push('flightdetails');
// this.navCtrl.navigateForward("flightdetails");
//this.router.navigate(['flightdetails']);
this.navCtrl.setRoot(this.flightdetailsPage);
//this.router.navigateByUrl('/flightdetails');
//this.navCtrl.push('flightdetails');
// this.navCtrl.navigateForward("flightdetails");
//this.router.navigate(['flightdetails']);
Try the below format:
Way 1:
this._router.navigate(["/welcome"], { queryParams: { data: "name" } });
to access the queryParams use:
this.router.snapshot.queryParams["data"];
syntax:
this.router.navigate([_path] , _data)
Way 2:
this._router.navigate(["/welcome", { data: "name" }]);
to access the data :
this.router.snapshot.params["data"]

Recommended workflow for tablesorter serverSideSorting?

Question for Mottie's tablesorter version 2.30.5.
What is the recommended workflow for serverSideSorting? More specifically, when / how do I apply / insert / update the table data coming back from the server such that I don't wipe out information like last.sortList?
I'm following Mottie's answer here as close as I can but I am unable to sort on multiple columns, because when I reinitialize tablesorter, it clears last.sortList.
jQuery("#search_results_table")
.on("sortEnd", function(e, table) {
jQuery('#search_sort').val(JSON.stringify(table.config.sortList));
// yuck
if (gTableSorterReady) {
// call server here, which calls this code on completion
}
})
.on("tablesorter-ready", function(e) {
// yuck
gTableSorterReady = true;
})
.tablesorter({
theme : 'search-theme',
widgets : [ 'zebra', 'stickyHeaders' ],
widthFixed : false,
widgetOptions : {
stickyHeaders_attachTo: '#search_results_container',
},
cssAsc : "headerSortUp",
cssDesc : "headerSortDown",
cssHeader : "header",
sortList : inSortList,
serverSideSorting: true
});

ASP.Net MVC validation not working with Bootstrap Select Picker

I've issue with ASP.NET MVC validation not working with Bootstrap Select Picker, If I remove the selectpicker class from dropdown list the validation working fine and if I added it the validation not working , Any help please
The MVC Code :
#Html.DropDownListFor(m => m.SelectedLocationID, Model.lstOfLocations, "Select Delivery Location", new { #class = " selectpicker", #placeholder = "" })
#Html.ValidationMessageFor(m => m.SelectedLocationID)
The Jquery Code With Valida-min.js
$(".SearchForm").validate({
ignore: ':not(select:hidden, input:visible, textarea:visible)',
rules: {
SelectedLocationID: {
required: true
}
},
errorPlacement: function (error, element) {
if ($(element).is('Select Delivery Location')) {
element.next().after(error);
} else {
error.insertAfter(element);
}
}
})
Thanks
I stumbled upon this question while searching for fix for same issue.
The problem arises from fact, that Bootstrap hides original select element and creates it's own elements to handle UI for dropdown list. In the meantime, jQuery validation by default ignores invisible fields.
I fixed this with workaround which combines changing validation ignore list and finding parent form. Final code snippet in my case looks like this
if ($(".selectpicker")[0]) {
$(".selectpicker").selectpicker();
$('.selectpicker').parents('form:first').validate().settings.ignore = ':not(select:hidden, input:visible, textarea:visible)';
}
There still could be potential issues, but for my needs this solution works good enough.
The problem is caused by the display:none property given from bootstrap select skin to the original select (jQuery validate ignores hidden fields).
It could be avoided working only with CSS keeping back visible the original select but giving it some properties to avoid visibility
select.bs-select-hidden, select.selectpicker
{
display:block !important; opacity:0; height:1px; width:1px;
}
I guess, editing of bootstrap-select.js may solve this issue permanently.
I have tried something like this:
$(document)
.data('keycount', 0)
.on('keydown.bs.select', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', Selectpicker.prototype.keydown)
.on('focusin.modal', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', function (e) {
//Validation handler: Kartik
var $thisParent = $(this).parent(".bootstrap-select");
if ($thisParent.find("ul").find("li:first").hasClass("selected")) {
if ($thisParent.next("span").length > 0)
$thisParent.next("span").css("display", "block");
}
else {
if ($thisParent.next("span").length > 0)
$thisParent.next("span").css("display", "none");
}
e.stopPropagation();
});
Its working fine to me.

Unable to pass additional parameters in plupload

I'm using plupload, the JQuery UI implementation. I'm trying to pass additional parameters to the server, but I can't make it work. It should be pretty straightforward, the parameters are already set when the function is executed, so that should not be a problem. I've tried this:
function GetPlUploader(m)
{
$("#divOpplaster").plupload(
{
// General settings
runtimes: 'flash,html5,silverlight',
url: 'upload.php',
max_file_size: '10mb',
chunk_size: '1mb',
unique_names: true,
multipart: true,
multipart_params: [
{
'ordre': ordreibruk,
'mode': m}
],
// Specify what files to browse for
filters: [
{
title: "Bildefiler",
extensions: "jpg,gif,png,bmp"}
],
// Flash settings
flash_swf_url: 'plupload/js/plupload.flash.swf',
// Silverlight settings
silverlight_xap_url: 'plupload/js/plupload.silverlight.xap',
init: {
FileUploaded: function(up, file, info)
{
// Called when a file has finished uploading
console.log('[FileUploaded] File:', file, "Info:", info);
}
}
});
console.log("Ordre: " + ordreibruk + ". Mode: " + m)
$("#divOpplaster").dialog(
{
autoOpen: false,
width: 650,
show: "fade",
hide: "fade"
})
$("#divOpplaster").dialog("open")
// Client side form validation
$('form').submit(function(e)
{
var uploader = $('#uploader').plupload('getUploader');
// Files in queue upload them first
if (uploader.files.length > 0)
{
// When all files are uploaded submit form
uploader.bind('StateChanged', function()
{
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed))
{
$('form')[0].submit();
}
});
uploader.start();
}
else
alert('Du må velge minst én fil for opplasting.');
return false;
});
}
I've also tried to add this in the $('form').submit section:
uploader.bind('BeforeUpload', function(up)
{
up.settings.multipart_params =
{
'ordre': ordreibruk,
'mode': m
};
});
But to no avail.
I'm sure I'm overlooking something really simple, but what?
Kind regards,
Anders
I must confess I use to put my parameters as query string parameters in the url :
during init : url: '/upload.aspx?id='+Id,
or later : upldr.settings.url = upldr.settings.url + '&token=' + myToken;
It works fine.
Hope this will help
Had the same issue. Stumbled upon this snippet that can easily translated into coffescript as well that works for my project. Allows you to pass multipart params after initialization (like in the case a field can change before the upload is hit)
var myUploader = $('#uploader').plupload('getUploader');
myUploader.bind('BeforeUpload', function(up, file) {
up.settings.multipart_params = {path : $("#path").val()};
});
Call it after you do your normal initialize and setup of $("#divOpplaster").plupload(...) (and set your ID appropriately to your uploader field, of course)

Resources