jstree massload in different ways - lazy-loading

I am using jstree lazy load to display large tree. I want to do
lazy search:
I want to search the database for all nodes matching the search string and display them in tree
I have done this by configuring a search API to return an array of ids of all the nodes which have to be opened to display the nodes matching the search
The search calls the massload internally, which then provides the data for each node id in a format as
{
"id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }],
"id2" : [{ "text" : "Child of ID2", "id" : "c3" }]
}
Lazy search works fine.
massload descendants on open_node:
Now, on expanding any node at level 5, I want to expand all its descendants.
Should I achieve this through massload? If so, can I make massload behave differently if called through search or if called through load_node?

Related

Apache Solr 7.4 : Nesting with "_childDocuments_" not working, the document is still flat

My use case is this : I have a Parent -> Children -> GrandChildren hierarchy.
I would like to ingest documents as nested and would like to do BlockJoin queries to retrieve all grandchildren of a particular parent, all children of particular parent etc.
I have defined the appropriate fields in the schema (using curl) and copy fields and field-types as required by my application. I have also defined "text" as a copy field for everything as I have to support random searches.
I have defined the document to ingest as follows :
{
"id": "3443",
"path": "1.employee",
"employeeId": 3443,
"employeeName": "Tom",
"employeeCounty": "Maricopa",
"_childDocuments_": [{
"id": "3443.54545454",
"path": "2.employee.assets",
"assetId": 54545454,
"assetName": "Lenovo",
"assetType": "Laptop",
"_childDocuments_": [{
"id": "3443.54545454.5764646",
"path": "3.employee.assets.assetType",
"processorId": 5764646,
"processorType": "Intel core i7"
}]
}]
}
Now when I query using the Admin UI, I am getting the following flattened out object, also block join queries don't work as well :
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"_":"1533252181415"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"3443",
"employeeId":3443,
"text":["3443",
"Tom",
"Maricopa"],
"employeeName":"Tom",
"employeeCounty":"Maricopa",
"_childDocuments_.id":[3443.54545454,
3443.643534544],
"_childDocuments_.path":["2.employee.assets],
"_childDocuments_.assetId":[54545454,
643534544],
"_childDocuments_.assetName":["Lenovo"],
What am I missing? How can I make Solr process the nested documents like they are supposed to be rather than flattening them out?
Any help is appreciated.
Found the solution. I was using the wrong URL to post.
I was using http://localhost:8983/solr/my-core/update/json/docs
Instead I should just use http://localhost:8983/solr/my-core/update
Because I am already formatting the doc in Solr format and Solr neednt do any special processing to index it.

Datatables Columndef "target" tied to an Editor

I have this problem in which I have a Datatable with a "columnDefs" attribute that contains 4 column definitions in which each column defines a "target" that calls a column index (i.e "targets": 1). That is fine. However, I also want to create a datatable editor (bubble editor to be exact) that has a "fields" attribute containing "label" and "name". How can I tie up the "label" field of my editor to the datatable which only has "columnDefs" attribute without declaring a "column" attribute ? Thanks in advance.
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/staff.php",
table: "#example",
fields: [ {
label: "First name:",
name: "first_name"

Rendering same component (with synced data) twice on same page

I've read a lot of documentation but I can't get the following use case to work:
I've got a component 'product-filter'. This component contains the child component 'product-filter-option' which renders a individual filter option (checkbox with label)
The json data for a product-filter instance looks like:
"name": "category",
"title": "Category",
"options": [
{
"value": "value",
"label": "Label 1",
"active": true,
"amount": 8
},
{
"value": "value2",
"label": "Label 2",
"amount": 15
},
etc.
]
I've got multiple instances of product-filter (and a lot of product-filter-option instances) on my page. So far so good.
Now I'd like to render one of my filters (eg. the given Category filter) multiple times on my page (sort of current 'highlighted' filter, which can change during user interaction).
So I've tried to fix this with the following template code:
<filter-component v-if="activefilter"
:name="activefilter.name"
:type="activefilter.type"
:title="activefilter.title"
:tooltip="activefilter.tooltip"
:configuration="activefilter.configuration"
:options="activefilter.options">
</filter-component>
So this filter now shows up 2 times on my page (only when the activefilter property in the vue app is set). But as you might guess when changing an option in this 'cloned' filter the original filter doesn't change, because the data is not synced between these 'clones'.
How can I fix this with Vue?
Thanks for your help!
#roy-j, thanks for your comment about sync. I already tried that by setting:
<filter-component v-if="activefilter"
:name="activefilter.name"
:type="activefilter.type"
:title="activefilter.title"
:tooltip="activefilter.tooltip"
:configuration="activefilter.configuration"
:options.sync="activefilter.options">
</filter-component>
This didn't work. But You got got me thinking, the options sync was not the issue, the sync of the 'checked' state was the issue.
It worked by changing :checked="option.active" to :checked.sync="option.acitve" to the child component: 'filter-option-component'!
Thanks!!

Displaying Only Certain Columns/Properties with Keen DataViz

I'm wondering how to display only certain columns on my table when I'm trying to do data visualization. Right now, every time that I do a table, it shows every single property or column. I tried to figure out how to only show certain columns properties by guessing based on the documentation for extraction within the keen.io docs (I've commented out my wrong guess)
var foo = new Keen.Query("extraction", {
eventCollection: "Purchases",
targetProperty: "zip",
// I've commented out line 7 because it doesn't work, it was just my guess on syntax...
// how do I only show certain columns of the table (columns are properties)
// vs. showing the entire table?
// propertyNames: ["zip","businessname"]
filters: [
{
"property_name" : "zip",
"operator" : "eq",
"property_value" : "80016"
},
{
"property_name" : "city",
"operator" : "eq",
"property_value" : "Aurora"
}]
});
client.draw(foo, document.getElementById("chart-09"), {
chartType: "table",
title: "Table"
});
https://gist.github.com/mrtannerjones/ba0cbd7340f2e016fcf2 - here is a link to the above code except on github in case something isn't formatted correctly.
Sorry if this question seems terribly basic or simple, I'm still really new at learning how to code.
Found the fix with a little help from David in the Keen.io Google group. I actually was just missing a comma after the 'property names', but what's more interesting to me is that the data visualization works with both camel case and with underscore separators. property_names and propertyNames both seem to work.

SAP UI5 - Not able to select more than one Check box in Table column

I have created a table with few columns getting data from Odata and i have created another column will have just check box.
My Code is
var oTable = new sap.ui.table.Table("Brand",{
title: "Brand List",
// visibleRowCount: 10,
//firstVisibleRow: 3,
selectionMode: sap.ui.table.SelectionMode.None,
navigationMode: sap.ui.table.NavigationMode.Paginator,
fixedColumnCount: 10,
width:"700px"
});
oTable.addColumn(new sap.ui.table.Column({
// visible: false,
label: new sap.ui.commons.Label({text: "Country"}),
template: new sap.ui.commons.TextView().bindProperty("text", "COUNTRY_ID"),
sortProperty: "COUNTRY_ID",
filterProperty: "COUNTRY_ID",
flexible : false,
width:"1px"
}));
//Define the columns and the control templates to be used
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Brand"}),
template: new sap.ui.commons.TextView().bindProperty("text", "BRAND"),
sortProperty: "CUSTOMER",
filterProperty: "CUSTOMER",
width:"250px"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "2013",textAlign:"Center"}),
template: new sap.ui.commons.CheckBox().bindProperty("checked","checked"),
sortProperty: "checked",
filterProperty: "checked",
width: "100px",
hAlign: "Center"
}));
It works fine when the table length is 10 ( defined in the table creation statement). But if my brand list is more than 10 ( some times it can be more than 100) , still the no. of check boxes is created is 10. so in the table if go to next page (paginator mode ) , the check boxes are still the same.
So if i select a brand in first page and select a brand in third page , the check box remains same. Its not creating check boxes except for the first page.
Please help me on this issue.
Thanks
Sathish
Attempt 2. This time, I'll try answer the question. Sathish, it appears as though your model does not account for the checkbox property. Your OData service is returned data to you (using JSON notation for simplicity) like this:
data : [{
"COUNTRY_ID" : "USA",
"BRAND" : "Nike"
},{
"COUNTRY_ID" : "GER",
"BRAND" : "Adidas"
},{
"COUNTRY_ID" : "ITA",
"BRAND" : "Lotto"
}]
But you are using the returned model as if there is a third property in each object, named 'checked'. E.g.
data : [{
"COUNTRY_ID" : "USA",
"BRAND" : "Nike",
"checked" : false
},{
"COUNTRY_ID" : "GER",
"BRAND" : "Adidas",
"checked" : false
},{
"COUNTRY_ID" : "ITA",
"BRAND" : "Lotto",
"checked" : false
}]
If this property is not part of the model, then you effectively have nothing to bind your checkbox to. Because the property does not exist in the model, the check box column is not bound to anything. When the table is initialised to 10 rows, that is the number of checkbox controls you've created, no more. Once you begin paginating, the number rows never changes, but the pagination binds the next 10 rows of your OData dataset to the table rows and columns. Because the dataset doesn't contain the property 'checked' (my assumption), the column listing the checkboxes is not rebound to the model's data, thus the checked checkboxes never change.
I would suggest you do one of two things - update the OData service to include this additional property (checked), and bind the checkbox column to that property, or two, copy the model data to a new model, add the 'checked' property to each object in the collection, and then bind your table to this new model. Either way, you need to ensure that the model has a property to which you can bind the checkboxes.
This link to an editable Table control demonstrates the principal I'm referring to:
Editable Table control
In this example, the author is making a table editable by using the 'editable' property in each object in his collection. This property, which exists for every entry in the model's data, is bound to the TextField control in the table's second column.
template: new sap.ui.commons.TextField({
value: '{lname}',
editable: '{edit}' // Binding editable property of text field to 'edit' attribute of Model
}),
You'll need to do something very similar, but for the Checkbox, ensuring the model has a property to bind to.
Good luck.