I am trying to find a way to refresh or update a listview without reloading the page.
Here is a brief example
I have a custom doctype named Mydoctype
It has 3 fields A B C
C is a link to another doctype which contains a link to a third doctype named Developer
Developer has a field named initials.
I want my list view to show the initials field of the linked Developer doctype
I have created a custom Mydoctype_list.js
frappe.listview_settings['Mydoctype'] = {
prepare_data: function(data) {
//console.log(locals);
//data.rep = "sdfasdfasdfasdfa";
frappe.call({
method: "mydoctype.mydoctype.doctype.Developer.Developer.getRepinitials",
args: {"name": data.name },
callback: function(r) {
var rep = r.message[0]
// console.log("data.name=" + data.name + " rep data returned=" + rep);
data.rep = rep;
}
});
},
refresh: function(doclist) {
setTimeout(function(){
console.log(doclist.data);
for(a in doclist.data){
console.log(a);
//doclist.refresh();
//a.rep = "tTyT";
}
},500);
}
};
This works correctly. I can see by inspecting my console that the rep field is correctly updated but since it happens in a callback it doesnt show on the page since it has already been rendered.
Is there a way to cause the table to refresh its backing data similar to frm.refresh_field
How do I get a reference to frm?
Alternatively, can I override the function that actually loads the data with my own function that correctly gets the 4 fields I need.