Hi Friends, wanting to customise dialog by converting it to a grid/table of rows so user can select multiple profiles and confirm see screen shot. I cannot get the confirm button to fire see (submit.click) . I also noticed that the AJAX call is not firing on fail -success does not work, have not implemented yet- it does not call someFunction. any help please.
here is the code
/* ADD A BUTTON */
refresh: function (frm) {
frm.add_custom_button(“do somehing”, function () {
/* BUILD THE GRID-TABLE */
var mytable = $("<table></table>").attr({id: "basic"});
var tblBody = $("<tbody></tbody>").attr({id: "tblProfile"});
var row_count = 4;
var col_count = 4;
for (var row = 0; row < row_count; row++) {
var tr = $("<tr></tr>").attr({class: "rowKK"});
var inputContainer = $("<td></td>");
inputContainer.append($('<input>', {id: "cb", type: "checkbox", name: "cb"}));
tr.append(inputContainer);
for (var col = 0; col < col_count; col++) {
var cell = $("<td></td>");
var cellText = cell.append(document.createTextNode("r" + row + "c " + col));
cell.appendTo(tr);
}
tr.appendTo(tblBody);
}
var submitAndDiv = $("<div></div>").append($('<input>', {
id: "submit12",
type: "submit",
name: "submit12",
value: "Confirm1"
}));
/* COLLECT CHECKED BOXES SELECTED */
var submit = submitAndDiv.find("input");
submitAndDiv.appendTo(tblBody);
submit.click = function () {
console.log("here");
user_selection = {
results: []
};
data = [];
datalines = $("input[name='cb']:checked").siblings("td");
$.each(datalines, function () {
data.push($(this).text());
data.map(function (item) {
user_selection.results.push({
"col": item
});
});
});
//populate(user_selection);
return false;
};
tblBody.appendTo(mytable);
profile = document.getElementById("tblProfile");
/* AJAX CALL HERE */
function doAjax(url, data, success, callback) {
.fail(
function (callback) {
callback = "hhhh";
someFunction(callback);
return callback;
})
.success(
function (callback) {
callback = "hhhh";
someFunction(callback);
return callback;
})
}
function someFunction(callback) {
alert(callback);
}
var dialog = new frappe.ui.Dialog({
title: __("Customer Profile"),
fields: [{'fieldname': 'today', 'fieldtype': 'Date', 'default': frappe.datetime.nowdate()},
{"fieldname": "ht", "fieldtype": "HTML"},
{"fieldname": "ConfirmBtn", "fieldtype": "HTML"}
]
});
dialog.fields_dict.ht.$wrapper.html(mytable.html());
dialog.fields_dict.ConfirmBtn.$wrapper.html(submit);
dialog.show();
});
}