1/5/2014 12:00:00 AM
<script language="javascript" type="text/javascript">
var editid;
var count = 0;
var incld = "";
var i = 0;
$(document).ready(function() {
GattableList();
});
function GattableList() {
//
$.get(
"/TestTask/TaskList/",
null,
function(data) {
$("#ListDiv").html(data);
$(".btnEdit").bind("click", Edit);
$(".chka").bind("click", checkUncchk);
}
);
}
function Edit() {
if (count == 0) {
var par = $(this).parent().parent(); //tr
//var d = $('#tblt tr td').attr('id');
//alert(d);
var ed;
var tdButtons = par.children("td:nth-child(1)");
var tdInclude = par.children("td:nth-child(2)");
var tdBinderType = par.children("td:nth-child(3)");
var tdNoteType = par.children("td:nth-child(4)");
var tdQuickNotes = par.children("td:nth-child(5)");
// tdInclude.html("<input type='checkbox' id='incl' >");
$("#tblt tr td:nth-child(1)").click(function() {
eid = $(this).attr('id');
eid = eid.trim();
//alert(eid);
var tempinc = new Array();
tempinc = eid.split("/");
i = tempinc[0];
//alert(i);
incld = tempinc[1]
tdButtons.html("<button class='btn btn-danger btn-small' Onclick='Save(" + i + ");'>Save</buton>" + " " +
"<button class='btn btn-danger btn-small' Onclick='Loadgrd();'>Cancel</buton>");
if (incld.trim() == "True") {
tdInclude.html('<label><input type="checkbox" id="incl"></label>');
$('#incl').attr("checked", "checked");
}
else {
tdInclude.html('<label><input type="checkbox" id="incl"></label>');
}
}
);
// //alert(eid);
// var inc = tdInclude.html();
// alert(inc);
// //var dc = document.getElementById('Include').checked
// // var inld = $("#Include").attr("checked");
// // alert(inld);
// if (inc.trim() == "True") {
//
// tdInclude.html('<input type="checkbox" id=incl>');
// $('#incl').attr("checked", "checked");
// }
// else {
// tdInclude.html('<label><input type="checkbox" id="incl"></label>');
// }
//var myinclude = tdInclude.html();
//tdInclude.html("<input type='checkbox' id='myinclude' >");
//alert(i);
//while (i == 0) {
// if ($('#Include' + i).attr('checked')) {
// //alert('hi');
// }
// else {
// //alert('bye');
// $('#myinclude').attr("checked", "checked");
// }
// }
// if ($('#Include' + i).is(':checked')) {
// //alert('hi');
// //$('#myinclude').attr("checked", "checked");
// }
// else {
// //$('#myinclude').attr("checked", "checked");
// }
var str = tdBinderType.html();
var temp = new Array();
str = str.trim();
temp = str.split(",");
//tdInclude.html('<input type="checkbox" id="incl">');
tdBinderType.html('<label>Select</label><br/><div style="z-index: 10;position:absolute;background-color:White;width:100px;border:1px;border-style:ridge;border-width:thin">' +
'<label><input type="checkbox" id="10">10</label><br/>' +
'<label><input type="checkbox" id="9">9</label><br/>' +
' <label><input type="checkbox" id="20">20</label><br/>' +
' <label><input type="checkbox" id="30">30</label><br/>' +
'<label><input type="checkbox" id="40">40</label><br/>' +
'<label><input type="checkbox" id="50">50</label><br/>' +
'<label><input type="checkbox" id="60">60</label></div>');
//tdBinderType.html('<label><input type="checkbox" id="9">9</label>' +
// ' <label><input type="checkbox" id="10">10</label>' +
// ' <label><input type="checkbox" id="11">11</label>' +
// '<label><input type="checkbox" id="12">12</label>');
var myval = tdNoteType.html().trim();
tdQuickNotes.html("<input type='text' id='txtQuickNotes' value='" + tdQuickNotes.html() + "'/>");
tdNoteType.html('<select id="mydd">' +
'<option value="Review">Review</option> ' +
'<option value="General">General</option> ' +
'<option value="Permanent">Permanent</option> ' +
'<option value="Missing">Missing</option> ' +
'</select>');
$.each(temp, function(i, e) {
// var e1 = '#' + e;
//$('#' + e).prop("checked", true);
$('#' + e).attr("checked", "checked");
});
$('#mydd').val(myval);
// var myinclude = tdInclude.html();
// alert(myinclude);
// tdInclude.html("<input type='checkbox' id='include'>");
// if (myinclude.trim() == "true") {
// $('#').attr("checked", "checked");
// }
//
// var incld = tdInclude.html();
// if (incld.trim() == "True") {
// tdInclude.html('<label><input type="checkbox" id="incl"></label>');
// $('#incl').attr("checked", "checked");
// }
// else {
// tdInclude.html('<label><input type="checkbox" id="incl"></label>');
// }
// if ($('#Include'+i).attr('checked')) {
// // alert('hi');
// }
// else {
// //alert('bye');
// $('#incl').attr("checked", "checked");
// }
// var $formElements = $('#tblt tr td').find(':checkbox').filter(function() {
// var c = $(this).attr('checked');
// alert(c);
// return;
// });
//
count = count + 1;
}
else {
alert('All ready one row in edit Mode!!!!!!!!!!!');
return;
}
}
function Save(id) {
var bindert="";
//alert(id);
var inlcd = document.getElementById('incl').checked;
var drp = document.getElementById('mydd').value;
var qun = document.getElementById('txtQuickNotes').value;
//var nine = document.getElementById("9").checked;
//alert(nine);
// if (nine == "True") {
// alert(nine);
// bindert += 9 + ","
// }
if ($('#9').attr('checked')) {
bindert += 9 + ","
}
// var ten = document.getElementById('10').checked;
//var bis = document.getElementById('20').checked;
// var tis = document.getElementById('30').checked;
//var chal = document.getElementById('40').checked;
//var pach = document.getElementById('50').checked;
//var sat = document.getElementById('60').checked;
if ($('#10').attr('checked')) {
bindert += 10 + ","
}
if ($('#20').attr('checked')) {
bindert += 20 + ","
}
if ($('#30').attr('checked')) {
bindert += 30 + ","
}
if ($('#40').attr('checked')) {
bindert += 40 + ","
}
if ($('#50').attr('checked')) {
bindert += 50 + ","
}
if ($('#60').attr('checked')) {
bindert += 60 + ","
}
$.post(
"/TestTask/EditRecord/" + id,
{ incl: inlcd, btype: bindert, ntype: drp, qn: qun },
function(data) {
$("#sds").html(data);
GattableList();
count = 0;
}
);
// alert(bindert);
// alert(qun);
// alert(inlcd);
// alert(drp);
}
function Loadgrd() {
GattableList();
count = 0;
}
function DeleteRec(id) {
$.post(
"/TestTask/DeleteRecord/" + id,
null,
function(data) {
$("#xzx").html(data);
GattableList();
count = 0;
}
);
}
function checkUncchk() {
var par = $(this).parent().parent();
var tdInclude = par.children("td:nth-child(2)");
var myinclude = tdInclude.html()
if ($('#chkall').attr('checked')) {
//alert("hi");
$('.case').attr('checked', this.checked);
}
else {
$('.case').removeAttr("checked");
}
}
</script>
<SCRIPT language="javascript">
$(function() {
// add multiple select / deselect functionality
$("#chkall").click(function() {
$('.case').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$(".case").click(function() {
if ($(".case").length == $(".case:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}
});
});
</SCRIPT>