the "target:_blank" param on "formatter:link" don't work.
I have this code
{width:40, align:"center", field:"pdf", formatter:"link", headerSort:false, formatterParams:{target:"_blank", label:pdfIcon, urlPrefix:"...myURL..."}}
Can you help me please?
Related
Dear Stackoverflow Members
I am currently looking for ways to call a link or URL within a multipage Dash app, and look suggestions with regards to the definition of the callback.
Initial Thought:
#html.Div('old', style= {'display':'inline-block', 'float':'left'}), html.Div(dcc.Link(daq.BooleanSwitch(id='test-switch', on=False, style= {'display':'inline-block', 'float':'left', 'margin-left': '1px'}), href='/testURL')),
Callback definition:
#app.callback(
Output('boolean-switch-output-1', 'children'),
Input('test-switch', 'on')
)
def render_url(flag):
if flag == True:
return '/testURL' # fails in calling /testURL
where /testURL has successfully been defined in testURL.py through:
register_page(__name__, path='/testURL')
N.B: In the meantime, I am using as a workaround:
html.Div('old', style= {'display':'inline-block', 'float':'left'}), html.Div(html.A(daq.BooleanSwitch(id='test-switch', on=False, style= {'display':'inline-block', 'float':'left', 'margin-left': '1px'}), href='/testURL', target='_blank'))
Thanks in advance for your clarification.
My solution has eventually consisted of adding a function.js within the
Clientside Callback :
app.clientside_callback(
"""
function(val) {
if (val === true) {
return window.open('/testURL', '_blank').focus();
} else {
//pass
}
}
""",
Output('boolean-switch-output-1', 'children'),
Input('test-switch', 'on')
)
N.B: Hope It would help someone facing similar challenges.
Best
Using latest Tabulator version 4.4.
I need to trigger an event so I can capture the info about the row moved from one table to the next.
The move works fine in the browser but there is never anything triggered, at least that I can see, that tells me what was moved.
I've tried
rowMoved:function(row){
//row - row component
}
but it never happens. I tried on both sender and receiver.
I have a table with all possible questions, and another which will hold only specific questions dragged to it.
var allquestions = new Tabulator("#allquestions", {
ajaxURL : "includes/retrievequestions.php?id=All",
rowMoved:function(row){
//row - row component
alert("row moved ");
},
height:"300px",
layout:"fitColumns",
pagination:"local",
movableRows:true,
movableRowsConnectedTables:"#thistemplatequestions",
placeholder:"No Data Set available",
paginationSize:40,
paginationSizeSelector:[100, 200, 500, 1000],
movableColumns:true,
columns:[
{title:"Question", field:"questiontext", sorter:"string", width:100, headerFilter:"input"},
{title:"Description", field:"questiondescription"},
{title:"Value", field:"questionvalue", align:"center", width:100},
],
});
var thistemplatequestions = new Tabulator("#thistemplatequestions", {
ajaxURL : "includes/retrievequestions.php?id="+$("#thisid").text(),
movableRowsConnectedTables:"#allquestions",
rowMoved:function(row){
//row - row component
alert("row moved ");
},
movableRowsReceiver: customReceiver,
height:"300px",
layout:"fitColumns",
pagination:"local",
placeholder:"No Data Set available",
paginationSize:40,
paginationSizeSelector:[100, 200, 500, 1000],
movableRowsReceiver: "insert", //add rows when dropped on the table.
columns:[
{title:"Question", field:"questiontext", sorter:"string"},
{title:"Description", field:"questiondescription" , headerFilter:"input"},
{title:"Value", field:"questionvalue", align:"center", width:100},
],
});
var customReceiver = function(fromRow, toRow, fromTable){
alert("customer receiver ");
//fromRow - the row component from the sending table
//toRow - the row component from the receiving table (if available)
//fromTable - the Tabulator object for the sending table
if(toRow){
toRow.update({"questiontext":fromRow.getData().questiontext});
return true;
}
return false;
}
Also tried customReciever with no luck either. it never triggered.
I'm sure it can be done, I just cant work out how.
Any help greatly appreciated.
Looks like your tabulator definition for thistemplatequestions has duplicates of movableRowsReceiver. Remove the second one (movableRowsReceiver: "insert", //add rows when dropped on the table.) and your customReceiver will then be executed.
EDIT:
According to Tabulator documentation:
Note: The movableRows option must be enabled on both tables to move
rows from one to the other.
It appears that you are missing movableRows: true in the thistemplatequestions Tabulator defintion.
Here is the snippet of code, based on yours, with the modifications I made to get things working:
var thistemplatequestions = new Tabulator("#thistemplatequestions", {
...
movableRows:true,
movableRowsReceiver: customReceiver,
...
});
function customReceiver(fromRow, toRow, fromTable){
//fromRow - the row component from the sending table
//toRow - the row component from the receiving table (if available)
//fromTable - the Tabulator object for the sending table
console.log("New Row Received!");
this.table.addRow(fromRow.getData(), undefined, toRow);
return true;
}
As the editor select
values: {
"steve": "Steve Boberson",
"bob": "Bob Jimmerson",
"jim": "Jim Stevenson",
}
I can find that this object key will be the value of cell data(see the picture), but can
it be similar with html select, I mean the select option text is for user, and the value is for the developer.
<select>
<option value="steve">Steve Boberson</option>
</select>
You should use the built in lookup formatter to do this:
{title:"Example", field:"example", formatter:"lookup", formatterParams:{
"small": "Cute",
"medium": "Fine",
"big": "Scary",
}}
you can pass the same object into the formatterParams as you do into the values property of the editorParams
I resolved this for my needs with a custom formatter. "metricList" is a variable that contains label and value populated by a DB. So the values are in "metricList".
The custom format then checks to see if there is a value in the cell, and if yes, find the Label for the value and return that.
{title:"Metric", field:"metricid", editor:"select", download:false,
editorParams: {
values: metricList
},
formatter:function(cell, formatterParams, onRendered) {
if (cell.getValue() > 0) {
return metricList.find(obj => obj.value == cell.getValue()).label
} else {
return ""
}
}
},
It works if using customize formatter to reformat the content which for user to see as the following link.
Visit https://jsfiddle.net/allensimth/zb6engfr
I'm new one Elasticsearch and elasticsearch_dsl and I've a problem, I want to make a research on md5 fields but I don't knows if I do it right.
Here is the file I've stored :
"data": {
"uniqueInfo": {
"md5_of_my_unique_info": "a3e2c73ab0aaze73881db1a889826ada",
}
md5_of_my_unique_info is a hash of lot of value and I want to make a research to know if it exist in the database so I do this :
es_host = {"host": "localhost", "port": 9200}
es = Elasticsearch(hosts=[es_host])
q = Q('bool',
must[Q('match', data__uniqueInfo__md5_of_my_unique_info=md5_value_I_want_Input)],
)
s = Search().using(es).query(q)
response = s.execute
for hit in s:
print(hit.meta.id)
I've test it on a bunch of data (15) and it seems to work but I can't test it on more data in test so can someone tell if I do it right ? if not How sould I do it ?
Thank you in advance to any one who could help me
I agree with JotaGe in the comment - this is fine if md5_of_my_unique_info is of type keyword (see [0] on how to set mappings in the dsl). Note that if you haven't done anything to the mappings you should have a keyword subfield automatically created for you by elasticsearch.
Using term query as a filter will also get you slightly better performance as elasticsearch won't have to try and calculate the score which shouldn't matter in your case, and you don't have to wrap your query in a bool query.
Overall your code would look like:
es_host = {"host": "localhost", "port": 9200}
es = Elasticsearch(hosts=[es_host])
s = Search().using(es)
s = s.filter('term', data__uniqueInfo__md5_of_my_unique_info__keyword=md5_value_I_want_Input)
response = s.execute
for hit in s:
print(hit.meta.id)
Hope this helps!
0 - http://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html#doctype
my mapping is like that :
"md5_of_my_unique_info": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
because I need to auto generate my mapping (I've json about 4000 lines)
thanks a lot for yours answer :)
I've read through the posts about dojox.Grid here, including the one about the tabcontainer, but it doesn't seem to solve my problem.
I have a grid that I am adding programmatically which works a treat if the grid is in the "main" markup, but ceases to display if I put the grid in a dialog.
Any ideas as to why? Using dojo 1.3.1.
dijit.byId("myDialog").show();
var gridStore = new dojo.data.ItemFileReadStore({
data : {
identifier : "id",
items : [
{"id" : 1, "label" : "foo"},
{"id" : 2, "label" : "bar"},
{"id" : 3, "label" : "baz"}
]
}
});
/* A simple layout that specifies column headers and
* mappings to fields in the store */
var gridLayout = [
{name : "ID", field : "id", width : "50%"},
{name : "Label", field : "label", width : "50%"}
];
/* Programmatically construct a data grid */
var grid = new dojox.grid.DataGrid({
store : gridStore,
structure : gridLayout
}, "gridNode");
/* Tell the grid to lay itself out since
* it was programmatically constructed */
grid.startup();
The markup is:
<div dojoType="dijit.Dialog" id="myDialog" title="Multiple Addresses" style="width:400px;height:300px" >
<div dojoType="dijit.layout.ContentPane" id="gridNode" style="positon:relative;width:100%;height:100%"></div>
Thanks for any help,
Ruprict
So, the problem I was having seeem to stem from not putting an explicit style on the grid container div (gridNode) Once I did this:
<div dojoType="dijit.layout.ContentPane" id="gridNode" style="width:400px;height:300px"></div>
It started working.
FYI. I am doing a similar thing (grid in a dialog) and have discovered if I try to modify the store (or at least call setStore on the grid) while the dialog is hidden, errors occur. Just something to watch out for.
I was creating all of it programatically so that didnt work for me, i had to connect to _getFocusItems method of the dialog, thats happen only the animation of the dialog ended.
lov.connect(lov,"_getFocusItems",dojo.hitch(this,function(){
var dijitTitle = new dijit.TitlePane({
title: "Resultados",
toggleable:false,
open:true,
style:"min-width:98%;display:inline-block;width:98%;height:"+dialogStyle.h-100+"px;",
baseClass:"dijitTitlePane qtResultsTitle"
},div);
dijitTitle.startup();
var fisaSubGrid = new dojox.grid.EnhancedGrid({
store:store,
structure: layoutRate,
autoHeight:"true",
autoWidth:true,
initialWidth:dialogStyle.w-50+"px",
plugins: {
pagination: {
description: false,
sizeSwitch: false,
pageStepper: true,
gotoButton: false,
maxPageStep: 5,
position: "bottom",
defaultPage: 2,
defaultPageSize: 10
}
}
});
dijitTitle.addChild(fisaSubGrid);
fisaSubGrid.startup();
}));