Prakash Kumar

Prakash Kumar

  • NA
  • 13
  • 4.1k

problem to hen i edit #jsgrid date format changed

Jul 6 2016 3:04 AM
<script>
$(function () {
$.ajax({
type: "GET",
url: "/Test/GetMerchant"
}).done(function (data) {
//$("#leftMenu").hide();
var MyDateField = function (config) {
jsGrid.Field.call(this, config);
};
MyDateField.prototype = new jsGrid.Field({
sorter: function (date1, date2) {
return new Date(date1) - new Date(date2);
},
itemTemplate: function (value) {
debugger
if (value == "")
return "";
else {
var date = new Date(value).toDateString("MM/dd/yyyy")
//return new Date(value).toDateString();
return value;
}
},
insertTemplate: function (value) {
debugger
return this._insertPicker = $("<input>").datepicker({ defaultDate: new Date() });
},
editTemplate: function (value) {
debugger
return this._editPicker = $("<input>").datepicker().datepicker("setDate", new Date(value));
},
insertValue: function () {
debugger
if (this._insertPicker.datepicker("getDate") != null)
return this._insertPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy")
else
return this._insertPicker.datepicker("getDate");
},
editValue: function () {
debugger
if (this._editPicker.datepicker("getDate") != null) {
//var RDAte = this._editPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy")
//var newdate = RDAte.toLocaleDateString('en-US')
//var d = new Date(newdate),
//month = '' + (d.getMonth() + 1),
//day = '' + d.getDate(),
//year = d.getFullYear();
//if (month.length < 2) month = '0' + month;
//if (day.length < 2) day = '0' + day;
////var df = [month, day, year].join('/');
//return [month, day, year].join('/');
return this._editPicker.datepicker("getDate");
}
//return this._editPicker.datepicker("getDate").toISOString();
else
//var RDAte = this._editPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy")
//var newdate = RDAte.toLocaleDateString('en-US')
//var d = new Date(newdate),
//month = '' + (d.getMonth() + 1),
//day = '' + d.getDate(),
//year = d.getFullYear();
//if (month.length < 2) month = '0' + month;
//if (day.length < 2) day = '0' + day;
////var df = [month, day, year].join('/');
//return [month, day, year].join('/');
//return this._editPicker = df;
return this._editPicker.datepicker("getDate");
}
});
jsGrid.fields.myDateField = MyDateField;
$("#jsGrid").jsGrid({
height: "50%",
width: "100%",
filtering: true,
editing: true,
inserting: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 12,
pageButtonCount: 5,
//pageLoading: true,
deleteConfirm: "Do you really want to delete the merchandise?",
controller: db,
fields: [
{ type: "control" },
{
name: "Source", type: "text", width: 120, title: "Vendor"
},
{
name: "Description", type: "text", width: 210,
validate: { message: "Description is required!", validator: function (value) { return value != ""; } }
},
{
name: "ModelNumber", type: "text", width: 120, title: "Model#/Item"
},
{ name: "SKU", type: "text", width: 90 },
{ name: "SKU2", type: "text", width: 90 },
{ name: "Comments", type: "text", width: 200 },
{ name: "strReceiveDate", type: "myDateField", width: 80, align: "center", title: "Received" },
{ name: "Location", type: "select", items: data.loc, valueField: "LocationID", textField: "Description", width: 100 },
{ name: "Barcode", width: 80 },
{ name: "BarcodePrinted", type: "checkbox", title: "Barcode Printed", sorting: false },
{ name: "strLastUpdatedDate", type: "myDateField", width: 80, title: "Last Updated" },
{ name: "DamageCode", type: "select", items: data.dam, valueField: "CodeID", textField: "CodeValue", title: "Damage" },
{ name: "strCreatedDate", type: "myDateField", width: 80, title: "Created Date" },
{ name: "strShipDate", type: "myDateField", myCustomProperty: "bar", width: 80, title: "Ship Date" },
{ name: "strConsumeDate", type: "myDateField", myCustomProperty: "bar", width: 80, title: "Consume Date" },
{ name: "PendingShipment", type: "checkbox", title: "Pending", sorting: false, width: 60 },
{ name: "Donated", type: "checkbox", title: "Is Donated", sorting: false, width: 60 },
{ name: "ReturnRequested", type: "checkbox", title: "Return Requested", sorting: false },
{ name: "ReturnTo", type: "text", width: 150, title: "Return To" },
{ name: "Quantity", type: "number", width: 50, title: "Qty" },
{ name: "GroupName", type: "text", width: 150, title: "Group Name" },
{ name: "CustomerID", width: 100, title: "Customer ID" },
],
});
});
});
</script>
 
this is my full code and when i edit #jsGrid then date save by default
("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)") format but i need 07/06/2016 this format