Hello Sir,
I am using Smart Client V10.0 for my project. I have been stuck in a phase where I need to change the value of a ListGrid field of type: "select" on clicking another field of type: "boolean" on the same List grid. I have pasted the code below. I will really appreciate if you can give me a helping hand in this. I have highlighted the code which depicts the fields I am referring. I want the status field should change its value as I tick the boolean checkbox in my selected field. Currently, its not changing as I am clicking the checkbox . Rather. if I'm clicking outside the checkbox,then its getting activated and then its changing the value of the status.
Code:
fields: [
{name: "description", type: "text", required: true,
validators: [
{type: "lengthRange", min: 1, max: 30}
]
},
{name: "selected", type: "boolean", width: 80,
changed: function(form, item, value) {
var record = item.grid.getRecord(item.rowNum);
if (value) {
if (record.origStatus && record.origStatus != lead.RegulatoryItemWindow.Status.CANCELED) {
record.status = record.origStatus;
record.ready = record.origReady;
record.sent= record.origSent;
}
else
record.status = lead.RegulatoryItemWindow.Status.REQUESTED;
}
else {
record.ready = null;
record.sent = null;
if (record.origStatus)
record.status = lead.RegulatoryItemWindow.Status.CANCELED;
else
record.status = record.origStatus;
}
item.grid.markForRedraw();
}
},
{name: "status", type: "text", width: 100,
editorType: "select",
editorProperties: {
defaultValue: "Y",
allowEmptyValue: false,
addUnknownValues: false
},
changed: function(form, item, value) {
var record = item.grid.getRecord(item.rowNum);
if (value == lead.RegulatoryItemWindow.Status.READY) {
record.ready = new Date();
record.sent = null;
}
else if (value == lead.RegulatoryItemWindow.Status.CLOSED) {
if (record.ready == null)
record.ready = new Date();
record.sent = new Date();
}
else {
record.ready = null;
record.sent = null;
if (value == lead.RegulatoryItemWindow.Status.CANCELED)
record.selected = false;
}
}
},
{name: "assigned", type: "text", width: 120},
{name: "ready", type: "date", width: 90,
validators: [
{type: "dateRange", max: new Date()}
]
},
{name: "sent", type: "date", width: 90,
validators: [
{type: "dateRange", max: new Date()}
]
}
],
canEditCell: function(row, col) {
var record = this.getRecord(row);
switch (col) {
case 0: // document
return record.code == lead.RegulatoryItemWindow.MISC && (record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED);
case 1: // selected
if (lead.RegulatoryItemWindow.allowClose)
return record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
else
return record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
case 2: // status
if (lead.RegulatoryItemWindow.allowClose)
return record.selected && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
else
return record.selected && (record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED);
case 3: // assigned
return false;
case 4: // ready date
return lead.RegulatoryItemWindow.allowClose && (record.status == lead.RegulatoryItemWindow.Status.READY || (record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED && record.status == lead.RegulatoryItemWindow.Status.CLOSED));
case 5: // sent date
return (record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED && record.status == lead.RegulatoryItemWindow.Status.CLOSED);
}
return false;
}
}
I will really appreciate your help in this. I am stuck in the mid of project execution due to this bug. Thanks in anticipation!
Regards,
Akash Mohapatra
I am using Smart Client V10.0 for my project. I have been stuck in a phase where I need to change the value of a ListGrid field of type: "select" on clicking another field of type: "boolean" on the same List grid. I have pasted the code below. I will really appreciate if you can give me a helping hand in this. I have highlighted the code which depicts the fields I am referring. I want the status field should change its value as I tick the boolean checkbox in my selected field. Currently, its not changing as I am clicking the checkbox . Rather. if I'm clicking outside the checkbox,then its getting activated and then its changing the value of the status.
Code:
fields: [
{name: "description", type: "text", required: true,
validators: [
{type: "lengthRange", min: 1, max: 30}
]
},
{name: "selected", type: "boolean", width: 80,
changed: function(form, item, value) {
var record = item.grid.getRecord(item.rowNum);
if (value) {
if (record.origStatus && record.origStatus != lead.RegulatoryItemWindow.Status.CANCELED) {
record.status = record.origStatus;
record.ready = record.origReady;
record.sent= record.origSent;
}
else
record.status = lead.RegulatoryItemWindow.Status.REQUESTED;
}
else {
record.ready = null;
record.sent = null;
if (record.origStatus)
record.status = lead.RegulatoryItemWindow.Status.CANCELED;
else
record.status = record.origStatus;
}
item.grid.markForRedraw();
}
},
{name: "status", type: "text", width: 100,
editorType: "select",
editorProperties: {
defaultValue: "Y",
allowEmptyValue: false,
addUnknownValues: false
},
changed: function(form, item, value) {
var record = item.grid.getRecord(item.rowNum);
if (value == lead.RegulatoryItemWindow.Status.READY) {
record.ready = new Date();
record.sent = null;
}
else if (value == lead.RegulatoryItemWindow.Status.CLOSED) {
if (record.ready == null)
record.ready = new Date();
record.sent = new Date();
}
else {
record.ready = null;
record.sent = null;
if (value == lead.RegulatoryItemWindow.Status.CANCELED)
record.selected = false;
}
}
},
{name: "assigned", type: "text", width: 120},
{name: "ready", type: "date", width: 90,
validators: [
{type: "dateRange", max: new Date()}
]
},
{name: "sent", type: "date", width: 90,
validators: [
{type: "dateRange", max: new Date()}
]
}
],
canEditCell: function(row, col) {
var record = this.getRecord(row);
switch (col) {
case 0: // document
return record.code == lead.RegulatoryItemWindow.MISC && (record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED);
case 1: // selected
if (lead.RegulatoryItemWindow.allowClose)
return record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
else
return record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
case 2: // status
if (lead.RegulatoryItemWindow.allowClose)
return record.selected && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED;
else
return record.selected && (record.origStatus != lead.RegulatoryItemWindow.Status.READY && record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED);
case 3: // assigned
return false;
case 4: // ready date
return lead.RegulatoryItemWindow.allowClose && (record.status == lead.RegulatoryItemWindow.Status.READY || (record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED && record.status == lead.RegulatoryItemWindow.Status.CLOSED));
case 5: // sent date
return (record.origStatus != lead.RegulatoryItemWindow.Status.CLOSED && record.status == lead.RegulatoryItemWindow.Status.CLOSED);
}
return false;
}
}
I will really appreciate your help in this. I am stuck in the mid of project execution due to this bug. Thanks in anticipation!
Regards,
Akash Mohapatra
Comment