Here is the function we use to set the row so the user can edit/ update
//The users clicked the edit button. Hide and show the proper column and format the column the data
function editJob(rowNum) {
var rowData = $("#list").getRowData(rowNum);
$("#subJobGridErrDiv").text("");
jQuery("#list").hideCol(["JobID", "Customer", "Edit", "Status", "DateChanged"]);
jQuery("#list").showCol(["Lead", "Promised", "Save", "Cancel", "StatusList"]);
$.blockUI();
$.ajax({
cache: false,
url: '/UpdateJobStatus/GetEditInfo/',
dataType: "json",
type: "post",
success: function(result) {
//getCellData gets the object in each cell. Using the object can find the value of the data. (simular to getHtmlText)
var note = $("#list").getCellData(rowNum, "Notes", "textArea");
//set the text box back to a string. before 'editRow'
jQuery("#list").setRowData(rowNum, { Notes: note });
$('#list').editRow(rowNum);
//remove $,',' and ending .00
var bidValue = $("#list").getCellData(rowNum, "Bid", "text");
bidValue = unFormatNumber(bidValue);
var bid = document.createElement("textarea");
$(bid).attr({ id: "bidBx", name: "bidBx", align: "right", editable: true, rows: "1″, cols: "11″ });
$(bid).text(bidValue);
$(bid).keypress(function(event) { $("#list").preventLetterEnter(event, $(bid).val()) });
$(bid).keyup(function(event) { $("#subJobGridErrDiv").text(""); validateBid($(bid).val()); });
jQuery("#list").setRowData(rowNum, { Bid: bid });
note = document.createElement("textarea");
$(note).attr({ id: "Notes", name: "Notes", rows: 3, cols: "27″ });
$(note).html($("#list").getCellData(rowNum, "Notes", "textArea"));
$(note).keyup(function() { verifyCommentCount($(note)) });
jQuery("#list").setRowData(rowNum, { Notes: note });
//set the TM check bx.
var tmCheckBox = $("#list").getCellData(rowNum, "TM", "checkBox");
tmCheckBox = (tmCheckBox) ? "checked='checked'" : "";
tmCheckBox = "<input type='checkbox' " + tmCheckBox + " />";
jQuery("#list").setRowData(rowNum, { TM: tmCheckBox });
//set the dropdown user list.
var userNameList = "<select name='userNameList' Enabled='true'>";
var uList = result.UserList;
for (var i = 0; i < uList.length; i++) {
var init = uList[i].substring(0, 1);
var name = uList[i].replace(init + ":", "");
if (init == "1″)
userNameList += "<option selected> " + name + "</option>";
else
userNameList += "<option>" + name + "</option>";
}
userNameList += "</select>";
jQuery("#list").setRowData(rowNum, { Lead: userNameList });
//set the status list
var statusDropDown = "<select name='statusList' Enabled='true'>";
var sList = result.StatusList;
for (var i = 0; i < sList.length; i++) {
var name = sList[i];
if (name == rowData.Status)
statusDropDown += "<option selected> " + name + "</option>";
else
statusDropDown += "<option>" + name + "</option>";
}
statusDropDown += "</select>";
jQuery("#list").setRowData(rowNum, { StatusList: statusDropDown });
//the save button add events
var saveImg = document.createElement("img");
$(saveImg).attr({ id: "saveBtn", name: "saveBtn", src: "../../Content/Images/newCheck.gif" });
saveImg.onclick = new Function("updateJobStatus(" + rowNum + ");");
jQuery("#list").setRowData(rowNum, { Save: saveImg });
//cancel button & click events
var cancelImg = document.createElement("img");
$(cancelImg).attr({ id: "cancelBtn", name: "cancelBtn", src: "../../Content/Images/newdelete.gif" });
cancelImg.onclick = new Function("cancelEdit(" + rowNum + ");");
jQuery("#list").setRowData(rowNum, { Cancel: cancelImg });
//add a datepicker to the text box in the promised column.
jQuery("#" + rowNum + "_Promised", "#list").datepicker({ dateFormat: "mm/dd/yy" });
$.unblockUI();
},
error: function(errorData) {
ErrorPopUp(errorData.responseText);
}
}
);
}