Fancytree enable/disable checkbox based on condition - fancytree

On fancytrees, I need a solution to enable or disable the checkbox based on a condition.
On the inspector my checkboxes elements are like this:
< span role="checkbox" class="fancytree-checkbox"/>
Can you please point me some directions?

I think, you can use this.
if(...){
$("#tree").fancytree("option", "checkbox", true});
}
else{
$("#tree").fancytree("option", "checkbox", false});
}

Related

How to expand rows in grouped data in Ag-grid angular?

I want to expand particular rows in table,on certain condition. But i actually want it during on-load of page, not on any click events.
The solutions i saw online are based on click events.
Can any one help me on it?
Listen to the gridReady event:
<ag-grid-angular [gridOptions]="gridOptions" (gridReady)="gridReady($event)"></ag-grid-angular>
And then loop though the nodes and determine whether or not you want it expanded:
gridReady = (params) => {
gridOptions.api.setData([yourData]);
gridOptions.api.forEachNode(function(node) {
// enter your expansion criteria here
if (node.key==='whatever') {
node.setExpanded(true);
}
});
}

Algolia autocomplete js with select2

I am using aloglia autocomplete.js and followed the tutorial.
I want to use autocomplete text box with others select2 selectbox.
var client = algoliasearch('YourApplicationID','YourSearchOnlyAPIKey')
var index = client.initIndex('YourIndex');
autocomplete('#search-input', { hint: false }, [
{
source: autocomplete.sources.hits(index, { hitsPerPage: 5 }),
displayKey: 'my_attribute',
templates: {
suggestion: function(suggestion) {
return suggestion._highlightResult.my_attribute.value;
}
}
}
]).on('autocomplete:selected', function(event, suggestion, dataset) {
console.log(suggestion, dataset);
$("#search-input").val(suggestion.full_name.name)
});
Problem is when I clicked anywhere beside that autocomplete box autocomplete disappear and it showed only what I typed before.
I don't want it to disappear. How can I implement it? Thanks for helping.
Please see the example below for detail problem.
Assume you have a simple form with one auto complete input field,two select2 boxes and one submit button. After you choose auto complete filed, when you click anywhere, it changed to default text. I mean, you put "piz" and it shows "pizza". Therefore you select pizza and it display "pizza".Then, you try to choose one select2 box or click anywhere. The autocomplete input field changed back to "piz".
I tried autocomplete:closed , $("#search-input").focusout to set the input field but it just changed back to my query.
To prevent it from disappearing, you can use autocomplete.js's debug option:
autocomplete('#search-input', { hint: false, debug: true }, [ /* ... */ ]);
The complete options list is available on GitHub.
Now I have it. When you need to only select and not to do any action, you can safety remove autocomplete:selected. And make sure your display key is value not object.
It saves me for trouble.

How can I remove items from Set when uncheck a checkbox ?

Hi guys. I have a tableView , which has one checkbox and one label in all rows.
So I tagged the checkboxes with labels. The goal is to make a set with clicked checkboxes. But the problem is I've done the checking and adding in set part. But I couldn't do unselecting part. --> I mean if I click the checkbox two times basically I deselect it so I have to remove the item from set, But I could't solve it.
If you can suggest something I ll be appreciated. Thanks.
func yourCheckBoxClicked(cbx:UIButton){
choosenSet.insert(self.tableData[cbx.tag])// this is the checkbox label which was clicked
print(choosenSet)
}
This is how you can achieve what you want:
func yourCheckBoxClicked(cbx:UIButton) {
let picked = tableData[cbx.tag]
if choosenSet.contains(picked) {
choosenSet.remove(picked) // uncheck
} else {
choosenSet.insert(picked) // check
}
}

how to add two different selection models in extjs panel

I have a grid with a customized selModel and cellediting plugin. Now I need to add also Checkbox Selection Model to it. Is this possible to have two selModels? Here is my existing code
selModel: Ext.create('TTT.MultiCellSelectionModel', {
mode: 'MULTI',
allowDeselect: true
}),
multiSelect: true,
selType: 'cellmodel'
as far as i know its not possible for grid having more than one SelectionModel.
but it could be done if you override or make new SelectionModel class which have your requirement.
Ext.define('TTT.CustomSelectionModel', {
extend: 'TTT.MultiCellSelectionModel',
// you can put your logic here
})
But you will need extra time for it.

jqgrid single select checkbox

In Jqgrid, I want to restrict user to select only one check box at any time. When user selects multiple check box only last selected to be in 'selected' state, remaining should be automatically un-selected.
I have set multi select attribute to true. But I am not able to do un-select previously selected item. Is it possible to do if so how?
Thanks
You can use the event beforeSelectRow and reset the selection:
beforeSelectRow: function(rowid, e)
{
jQuery("#list47").jqGrid('resetSelection');
return(true);
}
I've got a fiddle for you so you can check how it works.
You have to do some more stuff:
1. Set multiboxonly to true and multiselect to true
2. Define the events onSelectRow and beforeSelectRow:
3. Define global variable: var lastSel;
The OnSelectRow and beforeSelectRow implementation:
onSelectRow: function (rowId, status, e) {
if (rowId == lastSel) {
$(this).jqGrid("resetSelection");
lastSel = undefined;
status = false;
} else {
lastSel = rowId;
}
},
beforeSelectRow: function (rowId, e) {
$(this).jqGrid("resetSelection");
return true;
}
Having a checkbox in each column implies that you can click more than one at a time. What you are asking for is basically the multiselect: false behavior but with the checkbox column - are you sure you really want the checkboxes in this case?
I know this question is old, but I found a better solution in this Stack Post.
All you have to do is set the following two properties of the jqGrid:
multiselect:true // multi-select checkboxes appear
multiboxonly:true // checkboxes act like radio buttons where only one is selected at a time
I have updated the fiddle made by LeftyX to simply use the multiboxonly setting at this JsFiddle
This was what I needed. It may help someone else.