JoEz
December 28, 2016, 11:16am
1
Hi there,
any hint on how to create a pop up like Advanced Search
in Links
? see pic:
I found:
var d = new frappe.ui.Dialog({
'fields': [
{'fieldname': 'ht', 'fieldtype': 'HTML'},
{'fieldname': 'today', 'fieldtype': 'Date', 'default': frappe.datetime.nowdate()}
],
primary_action: function(){
d.hide();
show_alert(d.get_values());
}
});
d.fields_dict.ht.$wrapper.html('Hello World');
d.show();
but not very clear, thx in advance.
2 Likes
I think the field should be of Link also
JoEz
December 28, 2016, 4:08pm
3
@johnskywalker what u mean? I do not need links …i need to display values in the same way Advanced Search are shown, no need to be links …
yes, those functionalities works only if the fieldtype is Link
JoEz
December 28, 2016, 4:11pm
5
@johnskywalker so i can’t display values from a Doctype in a Dialog if not links?
what values do you want to show by the way? you can show values but Advanced Search and other functionality is only available for Links
JoEz
December 28, 2016, 4:20pm
7
@johnskywalker basically i’ve a DocType, Item Price History
and i want to display values in a Dialog
called from a custom button field in Item Price
, passing Item Code
and Price List
.
I would suggest having the button in every row of your item child table. So if you click on it, you will pass the particular item and display price history for that item only
JoEz
December 28, 2016, 4:30pm
9
@johnskywalker yes, i’ve a button on Item Price …btw i’m struggling on how to display data in the Dialog; i got i’ve to call a method, but i’m not getting how to display the result from callback …can u help?
I have created like this, try playing with it
cur_frm.cscript.price_bt = function (doc, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.call({
method: "path.to.your.python_script",
args: {
"item_code": d.item_code,
},
callback: function (r) {
console.log(r['message'].message);
if (r['message'].message) {
console.log("RIGHT HERE");
console.log(r['message'].message.length);
if (r['message'].message.length > 0) {
var html_str = '<b>Purchased</b><br><table class="table table-bordered" width="100%"><thead><tr>' +
'<th bgcolor="#F7FFFE">Date</th><th bgcolor="#F7FFFE">Supplier</th><th bgcolor="#F7FFFE">Country</th><th bgcolor="#F7FFFE">Rate</th></tr></thead>' +
'<tbody>'
for (i = 0; i < r['message'].message.length; i++) {
if (r['message'].message[i].status == "Purchased") {
html_str += '<tr><td>' + r['message'].message[i].date + '</td><td>' + r['message'].message[i].supplier + '</td><td>' +
r['message'].message[i].country + '</td><td>' + r['message'].message[i].rate + '</td></tr>'
}
}
html_str += '</tbody></table>'
html_str += '<b>Quoted</b><br><table class="table table-bordered" width="100%"><thead><tr>' +
'<th bgcolor="#F7FFFE">Date</th><th bgcolor="#F7FFFE">Supplier</th><th bgcolor="#F7FFFE">Country</th><th bgcolor="#F7FFFE">Rate</th></tr></thead>' +
'<tbody>'
for (i = 0; i < r['message'].message.length; i++) {
if (r['message'].message[i].status == "Quoted") {
html_str += '<tr><td>' + r['message'].message[i].date + '</td><td>' + r['message'].message[i].supplier + '</td><td>' +
r['message'].message[i].country + '</td><td>' + r['message'].message[i].rate + '</td></tr>'
}
}
html_str += '</tbody></html>'
console.log(html_str)
msgprint(html_str, 'Price List for ' + d.item_code);
}
else {
alert('No price list history for ' + d.item_code);
}
}
}
});
};
JoEz
December 28, 2016, 4:55pm
11
@johnskywalker Thx i’ll have a look!
jof2jc
June 19, 2017, 9:45am
13
Hi @johnskywalker i exactly have the same need to show customer price history…but user then can click the price for the history list…the selected price then applied to rate field of selected item.
Do you have an example to start to render the link per item list and manage the click action…
Thanks