I have a WebHierarchicalDataGrid that I dynamically build the boundcolumns and the rowedittemplate. When I add the RowEditingClientBinding, if the date in the bound column is empty the grid shows nothing in the column which is correct, but when the RowEditTemplate opens, in my textbox it displays the word "null". Also if the date is in the bound column is in short date format, when the RowEditTemplate opens, the date is displayed in long format. So how do I not show nulls and long dates in my textbox in the row edit template? I need a server side example only.
var item = new RowEditingClientBinding
{
ColumnKey = dataFieldName,
ControlID = clientId,
GetValueJavaScript =
,
SetValueJavaScript =
"').value={value}"
};
Grid.GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.ClientBindings.Add(item);
I figured this out. I created a javascript method to format the date and in the SetValueJavaScript of the RowEditingClientBinding, I wrapped it in the "value":
var item = new RowEditingClientBinding { ColumnKey = dataFieldName, ControlID = clientId, GetValueJavaScript = "$get('" + clientId + "').value", SetValueJavaScript = "$get('" + clientId + "').value=formatDate(new Date({value}),'MM/dd/yyyy')"
Grid.GridView.Behaviors.EditingCore.Behaviors.RowEditTemplate.ClientBindings.Add(item2);
//BLOCKED SCRIPT function formatDate(vDate, vFormat) { var vDay = addZero(vDate.getDate()); var vMonth = addZero(vDate.getMonth() + 1); var vYearLong = addZero(vDate.getFullYear()); var vYearShort = addZero(vDate.getFullYear().toString().substring(3, 4)); var vYear = (vFormat.indexOf('yyyy') > -1 ? vYearLong : vYearShort); var vDateString = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear); return vDateString; } function addZero(vNumber) { return ((vNumber < 10) ? '0' : '') + vNumber; }
Hi ratkinson,
I'm glad you figured this out. Another option would be to use one our our DateTimeEditor objects. This should accept null and display blank. You would just need to change the get and set bindings to use $find and then the client methods of the editor.
regards, David Young