I have a grid that has a description and 4 value columns. There are only 6 rows of records for this grid. In the first 4 rows, all 4 values are used with a label name. In the last two rows, only the 1rst value is used with a different label name. My question is If you click on one of the first 4 rows, I want the RowEditTemplate to display the labels and textboxes for editing all 4 columns, if one of the last two rows are clicked, I want to display only the labels & textboxes for editing the first column. Can I have more than one RowEditTemplate and, if so, how do I determine which one to use for the row clicked. If not, is there a way to do this, like if row 1-4 is clicked show such-and-such labels and textboxes, and if row 5-6 is clicked show only those labels and textboxes? This is a program requirement that I was able to do with a different third-party grid control in the past, but don't know how to do this with the UltraWebGrid. Thanks much for anyone who can help with this.
Hi dbishop9,
Thank you for your reply.
Can you debug your application in order to check whether:
igtbl_getElementById(templateId)
is returning the template element ? I can see no issues with the code you have posted (just note that in bother cases you are hiding the A div and showing the B div).
Please let me know if you need further assistance.
I just noticed my script has dipslay instead of display. I have changed this, but I still can't hide/unhide the rowedittemplates.
Hi Peter, thanks much. I'm not having any luck hiding the appropriate div though. Below is my javascript.
function igStop031_BeforeRowTemplateOpenHandler(gridName, rowId, templateId) { if (igtbl_getRowById(rowId).getIndex() == 4) { igtbl_getElementById(templateId).children["divGridControls_A"].style.dipslay='none'; igtbl_getElementById(templateId).children["divGridControls_B"].style.dipslay=''; } else if (igtbl_getRowById(rowId).getIndex() == 5){ igtbl_getElementById(templateId).children["divGridControls_A"].style.dipslay='none'; igtbl_getElementById(templateId).children["divGridControls_B"].style.dipslay=''; } }
Thank you for the sample code.
I have tested your setup in a content page of a master page and the javascript function seems to be operating as expected. Please note that in the moment you are reverting the the "initial" row edit template only after editing the row with index 5. Apart from that the elements in your template seem to accessed and modified correctly. Can you confirm for me that igtbl_getElementById(templateId) is returning the template ?
After more thought on the matter I can offer you a perhaps more straightforward approach - instead of accessing and modifying individual elements in your template, have a second main div in the template which contains its "modified" version for your 4th row. Then on the BeforeRowTemplateOpenHandler you can choose which div to display to the user.
<RowEditTemplate > <div id="divGridControls" > ........ </div> <div id="modifiedTemplateView" > </div> </RowEditTemplate>
<RowEditTemplate > <div id="divGridControls" >
........
</div>
<div id="modifiedTemplateView" >
</RowEditTemplate>
Please let me know if you have any questions.