/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/scripts/editablegrid.js
932 строки
34 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
var curLbl; var curTextParent; var curVal; var curshortTextLength; var pageX, pageY; var tid = 0; //Table id var formulas; var mode = "local";//"remote"; "local"; //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // ---- IMAGE LAZY LOADING //------------------------------------------------------------------------------------------------------------------------------------------------------------------ //window.addEventListener('load', function () { // var allimages = document.getElementsByTagName('img'); // for (var i = 0; i < allimages.length; i++) { // if (allimages[i].getAttribute('data-src')) { // allimages[i].setAttribute('src', allimages[i].getAttribute('data-src')); // } // } //}, false) //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // ---- INITIAL BINDING //------------------------------------------------------------------------------------------------------------------------------------------------------------------ var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function () { BindControlEvents(); }); $(document).ready(function () { BindControlEvents(); try { formulas = JSON.parse($("#edTableToView_formulas").val()); } catch (e) { } }); function BindControlEvents() { //Checking cursor position $(document).mousemove(function (e) { pageX = e.pageX; pageY = e.pageY; }); //--- Edit control $(".ajaxedit").dblclick(function () { bindEditEvent($(this)); }); $(".ajaxedit_click").click(function () { //console.log("!!!!"); bindEditEvent($(this)); }); //Condensed text $(".save").on("click", function () { //alert($(this).parents(".parent").get(0).getAttribute("tablename")); var parent = $(this).parents(".parent").get(0); var textParent = $(this).parent().get(0); var tabName = parent.getAttribute("tablename"); var recordId = parent.getAttribute("recordid"); var fieldName = parent.getAttribute("fieldName"); var shortTextLength = parent.getAttribute("shortTextLength"); var popupControlId = parent.getAttribute("popupControlId"); var txt = $(textParent).children().get(0); var lbl = $(parent).children().get(0); val = $(txt).val(); curLbl = lbl; curTextParent = textParent; curVal = val; curshortTextLength = shortTextLength; var srv = new DataHandler.Service(); srv.SaveData(tabName, recordId, fieldName, val, onSuccess, onFail, null); }); $(".close").on("click", function () { var popupForm = $(this).parent().get(0); $(popupForm).removeClass("popupFormShow"); $(popupForm).addClass("popupFormHide"); }); $(".activatePopup").on("click", function () { var parent = $(this).parents(".parent").get(0); var popupForm = $(parent).children(".popupFormHide").get(0); $(popupForm).addClass("popupFormShow"); $(popupForm).removeClass("popupFormHide"); }); //--Condensed text //--Form auto fill function $(".addFormControl").on("change", function () { var srv = new DataHandler.Service(); //console.log($("#" + $(this).attr("id") + " option:selected")); srv.GetFormData($("#edTableToView_lblTableName").val(), $(this).attr("fieldname") , $(this).val() , $("#" + $(this).attr("id") + " option:selected").text() , onFormSuccess, onFormFail) }) // Picture full view imagepreview(".thumbnail"); // -- Picture full view // ------------------------------------------------------------------------------------------------------- //Popup's //Excel download $(".exdown").click(function () { hidePopups(); var targetId = $(this).attr("id").replace("ExDown", "pnlEXcelDownloadOptions"); $("#" + targetId).removeClass("hidden"); //$("#" + targetId).center(); centerPopup($("#" + targetId)); }) //Send by email $(".sendemail").click(function () { hidePopups(); var targetId = $(this).attr("id").replace("ibSendEmail", "pnlMailRecepients"); $("#" + targetId).removeClass("hidden"); centerPopup($("#" + targetId)); //$("#" + targetId).center(); }) //Bulk data upload $(".dataupload").click(function () { hidePopups(); var targetId = $(this).attr("id").replace("DataUpload", "pnlDataUpload"); $("#" + targetId).removeClass("hidden"); centerPopup($("#" + targetId)); //$("#" + targetId).center(); }) //Delete all $(".deleteall").click(function () { hidePopups(); var targetId = $(this).attr("id").replace("ibDeleteData", "pnlDeleteAll"); $("#" + targetId).removeClass("hidden"); centerPopup($("#" + targetId)); //$("#" + targetId).center(); }) //Close popups $(".closepopup").click(function () { hidePopups(); }) // ------------------------------------------------------------------------------------------------------- //Grid actions // ------------------------------------------------------------------------------------------------------- $(".gridaction").click(function () { //alert($(this).attr("commandname")); try { showDialog($(this).attr("commandname")); } catch (e) { } }) /////////////// //Grid row command hanler $(".gridcommand").click(function () { try { var tableID = $(this).parent(0).attr("tid"); var field = $(this).parent(0).attr("field"); var rowid = $(this).parent(0).attr("rowid"); var commandName = $(this).attr("commandname"); var commandArgument = $(this).attr("commandargument"); gridCommand(tableID, field, rowid, commandName, commandArgument) } catch (e) { console.log(e); } }) //----------------------------------- centerPopup($(".pnlAddNewItem")); //------------------------------------------------------------------------------------------------------------ // File uploading //------------------------------------------------------------------------------------------------------------ $(".fileupload").on("click", function () { rownum = $(this).attr("rownum"); tid = $(this).attr("tid"); field = $(this).attr("field"); showmode = $(this).attr("showmode"); var p = $(this).position(); showfileupload(pageY + 10, pageX - 60); }) $(".cancelfile").on("click", hidefileupload); $(".savefile").on("click", uploadFiles); $('.selectedfile').on('change', prepareUpload); filedeletebind(".filedelete"); $(".canceldeletefile").on("click", hidefiledelete); $(".deletefile").on("click", deletefile); $(".rowdelete").on("click", rowdelete); $(".deleterow").click(function () { deleteRow($(this).attr("tid"), $(this).attr("rownum")); }); $(".canceldeleterow").click(function () { hidePopups(); }) calculateFormula(); // console.log("Start countTotals"); countTotals(); }; //------------------------------------------------------------------------------------------------------------------------------------------------------------------ function IsNumeric(input) { return (input - 0) == input && ('' + input).trim().length > 0; } function getCellValue(fieldName, rowNum) { var cnt = 0; var value = 0; $("[field='" + fieldName + "']").each(function () { if (cnt == rowNum) { if (IsNumeric($(this).text())) { value = $(this).text(); } else { value = 0; } return false; }; cnt = cnt + 1; }); return value; // + ":" + cnt; }; function calculateFormula() { $(".edtable").each(function () { tid = $(this).attr("tid"); try { formulas = JSON.parse($("#formulas_" + tid).val()); $("[tid='" + tid + "'][type='FORMULA']").each(function () { eval(eval("formulas." + $(this).attr("field")).replace(new RegExp("RowIndex", 'g'), $(this).attr("rownum"))); $(this).text( $(this).text().replace(/\.00$/, '')); }); } catch (e) { } }) }; function countTotals() { //console.log("COUNTING ......"); $(".edtable").each(function () { tid = $(this).attr("tid"); $("[tid='" + tid + "'][total='Y']").each(function () { var key = $(this).attr("field"); if (jQuery.inArray(key, category) != -1) { if ($.isNumeric($(this).text())) { $("body").data(key, $("body").data(key) + parseFloat($(this).text())); }; } else { category.push(key); if ($.isNumeric($(this).text())) { $("body").data(key, parseFloat($(this).text())); } else { $("body").data(key, 0); }; }; }); $.each(category, function (index, key) { $("[field='" + tid + "|Total|" + key + "']").text($("body").data(key).toFixed(2)); $("[field='" + tid + "|Total|" + key + "']").text($("[field='" + tid + "|Total|" + key + "']").text().replace(/\.00$/, '')); $("body").data(key, 0); }); category = []; }) }; $(document).keyup(function (e) { if (e.keyCode == 27) { hidePopups(); cancelEdit(); //cancelAdd(); } }); ///////////////////////// function centerPopup(popup) { if (typeof ($("#pnlAddNewItem")) != "undefined") { popup.removeClass("hidden"); popup.css("position", "absolute"); popup.css("top", (($(window).height() - popup.outerHeight()) / 2) + $(window).scrollTop() + "px"); popup.css("left", (($(window).width() - popup.outerWidth()) / 2) + $(window).scrollLeft() + "px"); //$("#pnlAddNewItem").center(); } } //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // ---- CONTROLS //------------------------------------------------------------------------------------------------------------------------------------------------------------------ var txt = ''; var value = ''; var cell; var savingCell; var txt; var value; var tmpControl; var elementType = ""; var itwascancel = false; ///hardcoding for cell click event var rownum, field, fileid; var category = []; function bindEditEvent(c) { if (itwascancel) { itwascancel = false; }else{ if (c.attr("class").indexOf("noclick") < 0) { if ((cell != null)) { SaveData(); }; cell = c; changeStatus(cell, "EDIT"); cell.html(getControl(c, c.parent().attr("rowid")) + (mode ==="remote"? //Remote "<br><img id='saveChanges' src='/modulemaster/images/buttons/set2/save.png' class='buttonImage icon_small' />" + " <img id='cancelChanges' src='/modulemaster/images/buttons/set2/no.png' class='buttonImage icon_small' />" //Local : "<br><img id='saveChanges' src='/images/buttons/set2/save.png' class='buttonImage icon_small' />" + " <img id='cancelChanges' src='/images/buttons/set2/no.png' class='buttonImage icon_small' />" )); $("#saveChanges").bind("click", function (e) { SaveData(); }); $("#cancelChanges").bind("click", function (e) { cancelEdit(); }); if ($("#foo").attr("type") == "checkbox") { } else if ($("#foo").attr("type") == "mark") { $("#foo").change(function () { var status = $(this).val(); $("tr[rowid='" + $(this).attr("rowid") + "']").each(function () { switch (status){ case "": $(this).addClass("white"); $(this).removeClass("red"); $(this).removeClass("yellow"); $(this).removeClass("green"); break; case "Y": $(this).removeClass("white"); $(this).addClass("yellow"); $(this).removeClass("red"); $(this).removeClass("green"); break; case "R": $(this).removeClass("white"); $(this).addClass("red"); $(this).removeClass("yellow"); $(this).removeClass("green"); break; case "G": $(this).removeClass("white"); $(this).addClass("green"); $(this).removeClass("red"); $(this).removeClass("yellow"); break; } }) }); } else { $("#foo").val(value); }; $("#foo").focus(); bindSubmit("#foo"); window.getSelection().removeAllRanges(); } } } function cancelEdit() { itwascancel = true; if (cell != null) { if ((elementType == "CHECKBOX") || (elementType == "MARK") || (elementType == "URL")) { cell.html(tmpControl); tmpControl = ""; elementType = ""; } else { cell.html(txt); }; changeStatus(cell, ""); cell = null; countTotals(); } }; function SaveData() { savingCell = cell; var request = $.ajax({ url: (mode === "remote" ? //Remote "/modulemaster/handlers/edGridEvHandler.ashx" //Local :"/handlers/edGridEvHandler.ashx"), data: { method: "saveData", tid: cell.attr("tid"), rowid: cell.attr("rowid"), field: cell.attr("field"), type: cell.attr("type"), value: $("#foo").val() } }); request.done(SaveDataSuccess); request.fail(SaveDataFail); changeStatus(cell, ""); cell.html((mode==="remote"?"<img src='/modulemaster/images/uploading.gif' />":"<img src='/images/uploading.gif' />")); cell = null; }; function SaveDataDirect(t, r, f, tp, v) { var request = $.ajax({ url: (mode === "remote" ? //Remote "/modulemaster/handlers/edGridEvHandler.ashx" //Local : "/handlers/edGridEvHandler.ashx"), data: { method: "saveData", tid: t, rowid: r, field: f, type: tp, value: v } }); //request.done(SaveDataSuccess); //request.fail(SaveDataFail); }; function SaveDataSuccess(result) { savingCell.html(result); changeStatus(savingCell, ""); // Call event handler----------------- try { dataSaved(savingCell.attr("tid"), savingCell.attr("rowid"), savingCell.attr("field"), result); } catch (e) { console.log(e); } savingCell = null; calculateFormula(); countTotals(); }; function SaveDataFail(result) { savingCell.text(result); savingCell.html(result); changeStatus(savingCell, "ERROR"); cellsavingCell = null; }; function getControl(_cell, rowid) { var _type = _cell.attr("type"); var _field = _cell.attr("field"); var _value = ""; switch (_type) { case "TEXT": value = _cell.text().replace(/ /g," "); value = _cell.text().trim(); txt = _cell.text(); return "<input type=\"search\" name=\"foo\" type=\"text\" id=\"foo\" field=\"" + _field + "\" rowid=\"" + rowid + "\" value=\"" + _cell.text() + "\">" case "TEXTBOX": value = _cell.html().replace(/<br>/g, "\n").replace(/ /g, " "); value = value.trim(); txt = _cell.html(); return "<textarea name=\"foo\" id=\"foo\" rows=\"2\" cols=\"15\">" + _value + "</textarea>"; case "ENCODED TEXT": value = _cell.html().replace(/<br>/g, "\n").replace(/ /g, " "); value = value.trim(); txt = _cell.html(); return "<textarea name=\"foo\" id=\"foo\" rows=\"2\" cols=\"15\">" + _value + "</textarea>"; case "CONDENSED TEXT": value = _cell.html().replace(/<br>/g, "\n"); txt = _cell.html(); return "<textarea name=\"foo\" id=\"foo\" rows=\"2\" cols=\"15\">" + _value + "</textarea>"; case "NUMBER": value = _cell.text(); txt = _cell.text(); return "<input name=\"foo\" type=\"number\" id=\"foo\" >"; case "DATE": value = _cell.text(); txt = _cell.text(); return "<input name=\"foo\" type=\"date\" id=\"foo\">"; case "TIME": value = _cell.text(); txt = _cell.text(); return "<input name=\"foo\" type=\"time\" id=\"foo\">"; case "CHECKBOX": tmpControl = _cell.html(); elementType = "CHECKBOX" value = _cell.children(0).is(':checked'); txt = _cell.children(0).val(); if (value) { return "<input id=\"foo\" type=\"checkbox\" name=\"foo\" checked=\"checked\" value=\"true\">"; } else { return "<input id=\"foo\" type=\"checkbox\" name=\"foo\" value=\"false\" >"; } case "MARK": elementType = "MARK" tmpControl = _cell.html(); var val = _cell.children(0).attr("val"); return "<select id=\"foo\" rowid=\"" + rowid + "\" type=\"mark\"> " + "<option " + (val==="" ? "selected=\"selected\"":"") + " value=\"\"></option>" + "<option " + (val === "R" ? "selected=\"selected\"" : "") + "value=\"R\">R</option>" + "<option " + (val === "Y" ? "selected=\"selected\"" : "") + "value=\"Y\">Y</option>" + "<option " + (val === "G" ? "selected=\"selected\"" : "") + "value=\"G\">G</option></select>" case "URL": tmpControl = _cell.html(); elementType = "URL" value = _cell.children(0).text();//.attr("href"); txt = _cell.children(0).text(); return "<textarea name=\"foo\" id=\"foo\" rows=\"2\" cols=\"15\"/>" // + txt + "</textarea>"; default: value = _cell.text(); txt = _cell.text(); //---------------------------------------------------------------------------- var request = $.ajax({ url: (mode === "remote" ? //Remote "/modulemaster/handlers/edGridEvHandler.ashx" : //Local "/handlers/edGridEvHandler.ashx"), data: { method: "getControl", tid: cell.attr("tid"), field: cell.attr("field"), type: cell.attr("type"), value: value } }); request.done(getControlSuccess); request.fail(getControlFail); return "" }; }; function getControlSuccess(result) { if (cell != null) { cell.html(result + (mode==="remote"? //Remote "<br><img id='saveChanges' src='/modulemaster/images/buttons/set2/save.png' class='buttonImage icon_small' />" + " <img id='cancelChanges' src='/modulemaster/images/buttons/set2/no.png' class='buttonImage icon_small' />": //Local "<img id='saveChanges' src='/images/buttons/set2/save.png' class='buttonImage icon_small' />" + " <img id='cancelChanges' src='/images/buttons/set2/no.png' class='buttonImage icon_small' />" )); $("#saveChanges").bind("click", function (e) { SaveData(); }); $("#cancelChanges").bind("click", function (e) { cancelEdit(); }); changeStatus(cell, "EDIT"); $("#foo").focus(); bindSubmit("#foo"); } }; function getControlFail(result) { alert("Can't connect to server. Try to refresh the page."); }; function changeStatus(control, status) { switch (status) { case "EDIT": control.removeClass("green"); control.removeClass("red"); control.addClass("blue"); control.addClass("noclick"); control.removeClass("click"); break; case "CHANGED": control.addClass("green"); control.removeClass("red"); control.removeClass("blue"); break; case "ERROR": control.removeClass("green"); control.addClass("red"); control.removeClass("blue"); break; default: control.removeClass("green"); control.removeClass("red"); control.removeClass("blue"); control.removeClass("noclick"); control.addClass("click"); }; }; function bindSubmit(controlName) { $(controlName).bind('keydown', function (e) { if ((e.which == 13) && (e.shiftKey == false)) { e.preventDefault(); SaveData(); return false; } }); $(controlName).bind('change', function (e) { if (cell != null) { if ($(this).attr("type") == "checkbox") { $(this).val($(this).is(':checked')); }; changeStatus(cell, "CHANGED"); } }); }; //-- Condensed text save result handlers function onSuccess(result) { if (result == "Saved") { if (curVal.length > curshortTextLength) { $(curLbl).text(curVal.substring(0, curshortTextLength) + "..."); } else { $(curLbl).text(curVal); }; $(curLbl).attr("title", curVal); $(curTextParent).removeClass("popupFormShow"); $(curTextParent).addClass("popupFormHide"); } else { alert("DB Error! Contact MI 2402"); }; }; function onFail(result) { alert("Error! Reload page or contact MI 2402"); }; //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // -- POPUP MANAGEMENT function hidePopups() { $(".popup").each(function () { $(this).addClass("hidden"); }) } //------------------------------------------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // -- FORM FIELDS UPDATE //------------------------------------------------------------------------------------------------------------------------------------------------------------------ function onFormSuccess(result) { if (result != '') { //console.log(result); var j = JSON.parse(result); //console.log(j); $.each(j, function (key, value) { if ($("#edTableToView_" + key)[0].tagName === "SELECT") { var sName = "#edTableToView_" + key; $(sName).empty(); $.each(value, function (key, value) { $(sName).append('<option value="' + value + '">' + key + '</option>'); //console.log(value); }) } else { $("#edTableToView_" + key).val(value); }; }); } }; function onFormFail(result) { }; //------------------------------------------------------------------------------------------------------------------------------------------------------------------ // ---- File OPERATION //------------------------------------------------------------------------------------------------------------------------------------------------------------------ function filedeletebind(binditem) { $(binditem).on("click", function () { fileid = $(this).attr("fileid"); tid = $(this).attr("tid"); rownum = $(this).attr("rownum"); field = $(this).attr("field"); showfiledelete(pageY + 10, pageX - 45); }) } function imagepreview(binditem) { $(binditem).on("click", function () { var curimage = $(this); if (curimage.attr("class") == "thumbnail") { curimage.removeClass("thumbnail"); curimage.attr("src", curimage.attr("src").replace("mode=thumb", "mode=full")); curimage.addClass("fullsize"); centerPopup(curimage); //curimage.center(); } else { curimage.css("position", "static"); curimage.removeClass("fullsize"); curimage.addClass("thumbnail"); curimage.attr("src", curimage.attr("src").replace("mode=full", "mode=thumb")); }; $(".fullsize").each(function () { if ($(this).attr("id") != curimage.attr("id")) { $(this).css("position", "static"); $(this).removeClass("fullsize"); $(this).addClass("thumbnail"); } }); }); } var files; var filename, showmode; function showfiledelete(top, left) { $("#confirmdeletefile_" + tid).removeClass("hidden"); $("#confirmdeletefile_" + tid).css("position", "absolute"); $("#confirmdeletefile_" + tid).css("display", "block"); $("#confirmdeletefile_" + tid).css("top", top); $("#confirmdeletefile_" + tid).css("left", left); } function hidefiledelete() { $("#confirmdeletefile_" + tid).css("display", "none"); } function showfileupload(top, left) { $("#choosefile_" + tid).removeClass("hidden"); $("#choosefile_" + tid).css("position", "absolute"); $("#choosefile_" + tid).css("display", "block"); $("#choosefile_" + tid).css("top", top); $("#choosefile_" + tid).css("left", left); } function hidefileupload() { $("#choosefile_" + tid).css("display", "none"); } // Grab the files and set them to our variable function prepareUpload(event) { files = event.target.files; filename = files[0].name; //event.target.files = []; } // File uploading logic function uploadFiles(event) { // START A LOADING SPINNER HERE // Create a formdata object and add the files var data = new FormData(); $.each(files, function (key, value) { data.append(key, value); }); data.append("tid", tid); data.append("rownum", rownum); data.append("field", field); //Clear files document.getElementById("selectedfile_" + tid).value = ""; document.getElementById("selectedfile_" + tid).innerHTML = document.getElementById("selectedfile_" + tid).innerHTML; $.ajax({ url: (mode==="remote"?'/modulemaster/handlers/uploadfile.ashx':'/handlers/uploadfile.ashx'), type: 'POST', data: data, cache: false, dataType: 'json', processData: false, // Don't process the files contentType: false, // Set content type to false as jQuery will tell the server its a query string request success: function (data, textStatus, jqXHR) { hidefileupload(); fileid = data[0].fileid; var newrow; if (showmode == 'FILE') { newrow = (mode==="remote"? "<tr id='row_&FILEID'><td class='noborder'><a href='/modulemaster/&FILEURL'>&FILENAME</a></td><td class='noborder'><img id='btnDeleteFile_&TID_&FILEID' title='Delete file' class='filedelete' fileid='&FILEID' tid='&TID' src='/modulemaster/Images/Buttons/set2/delete.png'></td></tr>": "<tr id='row_&FILEID'><td class='noborder'><a href='/&FILEURL'>&FILENAME</a></td><td class='noborder'><img id='btnDeleteFile_&TID_&FILEID' title='Delete file' class='filedelete' fileid='&FILEID' tid='&TID' src='/Images/Buttons/set2/delete.png'></td></tr>" ) } else { newrow = (mode==="remote"? "<tr id='row_&FILEID'><td class='noborder'><img id='img_&TID_&FILEID' class='thumbnail' src='/modulemaster/&FILEURL'></td><td class='noborder'><img id='btnDeleteFile_&TID_&FILEID' title='Delete file' class='filedelete' fileid='&FILEID' tid='&TID' src='/modulemaster/Images/Buttons/set2/delete.png'></td></tr>" : "<tr id='row_&FILEID'><td class='noborder'><img id='img_&TID_&FILEID' class='thumbnail' src='/&FILEURL'></td><td class='noborder'><img id='btnDeleteFile_&TID_&FILEID' title='Delete file' class='filedelete' fileid='&FILEID' tid='&TID' src='/Images/Buttons/set2/delete.png'></td></tr>" ) } newrow = newrow.replace(/&FILENAME/g, filename); newrow = newrow.replace(/&FILEID/g, fileid); newrow = newrow.replace(/&TID/g, tid); newrow = newrow.replace(/&FILEURL/g, data[1].url); $("#tblfiles_" + tid + "_" + rownum + "_" + field).append(newrow); if (showmode == 'PHOTO') { var imgid = '#img_&TID_&FILEID'; imgid = imgid.replace(/&TID/g, tid); imgid = imgid.replace(/&FILEID/g, fileid); imagepreview(imgid); } var deletebuttonid = '#btnDeleteFile_&TID_&FILEID' deletebuttonid = deletebuttonid.replace(/&FILEID/g, fileid); deletebuttonid = deletebuttonid.replace(/&TID/g, tid); filedeletebind(deletebuttonid); }, error: function (jqXHR, textStatus, errorThrown) { // Handle errors here console.log('ERRORS2: '); console.log(textStatus); console.log(errorThrown); console.log(jqXHR); // STOP LOADING SPINNER } }); } function deletefile() { var data = new FormData(); data.append("tid", tid); data.append("fileid", fileid); $.ajax({ url: (mode==="remote"?'/modulemaster/handlers/deletefile.ashx':'/handlers/deletefile.ashx'), type: 'POST', data: data, cache: false, dataType: 'json', processData: false, // Don't process the files contentType: false, // Set content type to false as jQuery will tell the server its a query string request success: function (data, textStatus, jqXHR) { hidefiledelete(); $("#row_" + fileid).html(""); }, error: function (jqXHR, textStatus, errorThrown) { // Handle errors here console.log('ERRORS2: '); console.log(textStatus); console.log(errorThrown); console.log(jqXHR); // STOP LOADING SPINNER } }); } function hideNotice() { $(".notice").each(function () { $(this).addClass("hidden"); }) } // Row delettion function rowdelete() { tid = $(this).attr("tid"); rownum = $(this).attr("rownum"); //console.log("row delete request "+ tid + " " + rownum); showrowdelete(pageY + 10, pageX - 45); $("#deleterowbutton_" + tid).attr("tid", tid); $("#deleterowbutton_" + tid).attr("rownum", rownum); } function showrowdelete(top, left) { $("#confirmdeleterow_" + tid).removeClass("hidden"); $("#confirmdeleterow_" + tid).css("position", "absolute"); $("#confirmdeleterow_" + tid).css("display", "block"); $("#confirmdeleterow_" + tid).css("top", top); $("#confirmdeleterow_" + tid).css("left", left); } function deleteRow(tid, rowid) { //console.log("delete row " + tid + " " + rownum); var request = $.ajax({ url: (mode === "remote" ? //Remote "/modulemaster/handlers/edGridEvHandler.ashx" //Local : "/handlers/edGridEvHandler.ashx"), data: { method: "deleteRow", tid: tid, rowid: rowid } }); request.done(deleteRowSuccess); request.fail(deleteRowFail); hidePopups(); } function deleteRowSuccess(result) { $("tr[tid='" + tid + "'][rowid=\"" + result + "\"]").attr("del", "Y"); $("tr[tid='" + tid + "'][rowid=\"" + result + "\"]").addClass("gray"); $("tr[tid='" + tid + "'][rowid=\"" + result + "\"]").children(".command:last").html(""); }; function deleteRowFail() { }; // ---------- Show - hide delete button --------------------------- //$("tr[class='gridrow']").on("mouseover", function () { //$("tr.gridrow").mouseover(function () { //$("td").mouseover(function () { // console.log("IN: " + $(this).attr("rownum")); // $(".rowdelete[rownum='" + $(this).attr("rownum") + "']").css("visibilty", "visible"); //}); //$("tr[class='gridrow']").on("mouseleave", function () { // console.log("OUT: " + $(this).attr("rownum")); // $(".rowdelete[rownum='" + $(this).attr("rownum") + "']").css("visibilty", "hidden"); //}); //$("tr").hover( // function () { console.log("in") } , // function () { console.log("out") }) function mover(rowid) { $(".rowdelete[rownum='" + rowid + "']").css("visibility", "visible"); $(".rowselect[rownum='" + rowid + "']").css("visibility", "visible"); //console.log($("tr[class='gridrow'][rowid='" + rowid + "'][class='filedelete']")); //$("tr[class='gridrow'][rowid='" + rowid + "'][class='filedelete']").css("visibility", "visible"); } function mout(rowid) { $(".rowdelete[rownum='" + rowid + "']").css("visibility", "hidden"); $(".rowselect[rownum='" + rowid + "']").css("visibility", "hidden"); } //Multiselect function saveMultiselectStat(controlName, values) { var oldValues = JSON.parse($("#edTableToView_controlState").val()); oldValues['\'' + controlName + '\''] = values; console.log(JSON.stringify(oldValues)); $("#edTableToView_controlState").val(JSON.stringify(oldValues)); }