Apparently the "Add Row" in the grid doesn't support use of the defined row edit template. In my view, this seems extremely limiting when using the grid as a record editor. For existing rows a well formatted, feature rich row edit template can be defined. For the addrow however, the user only has the basic edit fields in grid's add row.
I'd like to see the grid open the defined row edit template (if one has been defined) when adding a row - this seems intuitive, consistent, and non-confusing for an end user. The existing add row functionality is woefully inadequate.
Anyone have comments or thoughts on this?
Hello,
I have attached a sample project, that shows how the row edit template can be shown for the new row.
Hope this helps.
Regards,
Lyuba
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi Lyuba,
Thank you for this sample. It is very instructive even today. I have modified it for 2011.v1 and it sort of works. When I select add new, the template displays, but then it immediately dissapears and templateClosed is called.
Barry
<script type="text/javascript">
// flag used when the row edit template is closed to indicate if you should add new row
// set the flag to show that this is adding new
isAddingNew =
true;
//take the row editing template
var roweditingtemplate = grid.get_gridView().get_behaviors().getBehaviorByName("RowEditingTemplate"
);
//get the row adding behavior
roweditingtemplate.enterEditMode(rowaddingbehavior._row);
}
function initializeGrid(sender, args) {
var grid = $find("<%=WebHierarchicalDataGrid1.ClientID %>");
var rowaddingbehavior = sender.get_behaviors().get_editingCore().get_behaviors().get_rowAdding();
// add onclick event for the selector cell of the "add new" row
$addHandler(rowaddingbehavior._rowElement.cells[0],
"click", showEditRowTemplateOnAddNew);
function templateClosed(sender, args) {
// if new row is added and the OK button is clicked
var grid = $find("WebHierarchicalDataGrid1");
var rows = grid.get_gridView().get_rows();
var rowaddingbehavior = grid.get_gridView().get_behaviors().get_editingCore().get_behaviors().get_rowAdding();
var rowValuesArr = constructArray(rowaddingbehavior._row);
rows.add(rowValuesArr);
//reset the flag awlays
false;
function constructArray(row) {
var arr = new Array();
for (var i = 0; i < row._cells.length; i++) {
arr[i] = row._cells[i].get_value();
return arr;
</
script>
Thank you very much, that does help!
I am having a second issue with the RowEditTemplate that I'll address in a fresh post.