Hi,
I have and ultrawebgrid that is made up of two bands. When the user clicks a certain field (NDC) in the child band, it populates the NDC in the NDC column of the corresponding parent row. The parent NDC column is a hyperlink. My problem is when I execute my javascript (see below), it overwrites the hyperlink property and the field just looks like a normal text field. It no longer looks like a hyperlink. I have experienced this with some other columns on the grid as well which were text editable. Is there a way to have my javascript just update the text in the cell of the ndc parent column? Since initializeRow is not able to be called again, those properties are lost. Is there is a way to call initializeRow from the javascript to get the cell formatting back?
This is the statement in my javascript that updates the ndc value:
parentRow.getCellFromKey("templateLink").setValue(NdcFormatted);
Here is the definition of the parent column in the .aspx:
<igtbl:UltraGridColumn BaseColumnName="NDC" Key="NDC" Width="10%" Hidden="true"> <HeaderStyle Cursor="hand" CustomRules="padding-bottom:2px; border-left: solid 1px #c0c0c0" /> <Header Caption="NDC"></Header> <CellStyle CustomRules="border-left: solid 1px #c0c0c0" HorizontalAlign="Center"></CellStyle></igtbl:UltraGridColumn><igtbl:TemplatedColumn Key="templateLink" AllowResize="Fixed" Width="10%" AllowRowFiltering="False" > <Header Caption="NDC"> <RowLayoutColumnInfo OriginX="1" /> </Header> <HeaderStyle CustomRules="padding-bottom:4px; padding-top:4px; border-left: solid 1px #c0c0c0" /> <CellStyle HorizontalAlign="center" CustomRules="border-left: solid 1px #c0c0c0"></CellStyle> <CellTemplate> <asp:Button ID="lnkView" runat="server" CssClass="link" CommandName="grid_ItemCommand" CommandArgument="<%# Container.Cell.Row.Index %>" OnClientClick="ShowDetailTabDiv();return true;" ToolTip="View NDC Detail" TabIndex="-1" ></asp:Button> </CellTemplate> </igtbl:TemplatedColumn>
The InitializeRow event executes the following code:
If e.Row.Cells.FromKey("NDC").Text > " " Then tcol3 = e.Row.Cells.FromKey("templateLink").Column btn = CType(tcol3.CellItems(e.Row.Index).findcontrol("lnkView"), UI.WebControls.Button) btn.Text = String.Format("{0:00000-0000-00}", Int64.Parse(e.Row.Cells.FromKey("NDC").Text))End If
Here is the javascript I am using:
function toggleBand(cell){
row = igtbl_getCellById(cell.parentNode.id).Row; var oSelectedCell = igtbl_getCellById(cell.id); var grid = igtbl_getGridById("ResultPanelxReceiptGrid"); if (row != null) { //get the band var band = igtbl_getBandById(row.Element.id); if (band.Key == "OrderList") { row.setSelected(true); //expand/collapse the current row igtbl_toggleRow("ResultPanelxReceiptGrid", row.Element.id, !row.getExpanded()); } else { //if it is the child band we are going to get the parent //collapse the parent, select the parent, deselect the child var parentRow = igtbl_getRowById(row.ParentRow.Id); // set the ndc of the parent equal to the ndc of the child var NdcValue = row.getCellFromKey("NDC").getValue(); var NdcFormatted = NdcValue.substr(0,5) + "-" + NdcValue.substr(5,4) + "-" + NdcValue.substr(9,2); parentRow.getCellFromKey("templateLink").setValue(NdcFormatted); igtbl_toggleRow('ResultPanelxReceiptGrid', parentRow.Element.id, !parentRow.getExpanded()); row.setSelected(false); parentRow.setSelected(true); } }}
Thanks.
Hello tennisne1,
In the classic grid there is no, for example, “setText(…)” Client function, which is why you can use “setValue(value)” function to set the cell’s value.
In your scenario however you may use cell’s “TargetURL” property (you can find more info about it in your local documentation) to set the column cells text as hyperlink and then use Client-Side “setTargetURL(url)” cell function to change the hyperlink based on your requirements.
If you want to just refresh the grid from Client-Side you may try calling “show()” function:
var grid = igtbl_getGridById("grid1");
grid.show();
If you use grid with Xml Load on Demand you can also try:
grid.invokeXmlHttpRequest(grid.eReqType.Refresh);
I hope that this information will be useful.