Not sure if this is the correct place for this issue but here it goes.
On a very large project we have going at my company I am working on a screen in which I have 2 ultrawebgrids each in its own WARP panel, top grid is for Projects, bottom is for Clients. Each grid as an add and delete button and right now the delete buttons are disabled until the user clicks on a row in the grid to delete.
I click on a row in the top grid and the delete button for that grid is enabled. I click on a row in the bottom grid and the delete button for that grid is enabled. I click the top grid delete button and the row is deleted in an async postback. After the postback the bottom grid's cellclickhandler does not work anymore. I click on a row in the bottom grid and the delete button will not enable now even though the top one still works.
This is the javascript code, for the cellClick handler that enables the delete button
function grdProjects_CellClickHandler(gridId, cellId) { var btnDeleteProject = ig_getWebControlById('ctl00_ctl00_ContentPlaceHolder1_CoverageInformation_wgbxProjectTypes_btnDeleteProject'); btnDeleteProject.setEnabled(true); var btnDeleteProjectElement = btnDeleteProject.getElement(); btnDeleteProjectElement.style.cursor = 'hand'; } function grdClients_CellClickHandler(gridId, cellId) { var btnDeleteClient = ig_getWebControlById('ctl00_ctl00_ContentPlaceHolder1_CoverageInformation_wgbxClientTypes_btnDeleteClient'); btnDeleteClient.setEnabled(true); var btnDeleteClientElement = btnDeleteClient.getElement(); btnDeleteClientElement.style.cursor = 'hand'; }
This is my UltraWebGrid definition:
<igmisc:WebGroupBox ID="wgbxClientTypes" runat="server" Text="Client Types:" CssClass="Label"> <Template> <igmisc:WebAsyncRefreshPanel ID="warpClientTypes" runat="server" InitializePanel="warp_InitializePanel"> <table style="border-width: 0px; width: 100%; border-collapse: collapse;"> <tr> <td colspan="2"> <igtbl:UltraWebGrid ID="grdClients" runat="server" Browser="Auto" Height="125px" OnInitializeLayout="adjustmentGrids_InitializeLayout" OnInitializeRow="adjustmentGrids_InitializeRow" OnDataBound="adjustmentGrids_DataBound"> <DisplayLayout AllowSortingDefault="OnClient" BorderCollapseDefault="Separate" HeaderClickActionDefault="SortMulti" RowHeightDefault="5px" RowSelectorsDefault="No" StationaryMargins="Header" TableLayout="Fixed" Version="4.00" ViewType="Flat" AutoGenerateColumns="false" ColFootersVisibleDefault="No" CellClickActionDefault="Edit" AllowUpdateDefault="RowTemplateOnly" SelectTypeRowDefault="Single" ScrollBarView="Vertical" LoadOnDemand="NotSet"> <FrameStyle BackColor="Window" BorderStyle="Solid" BorderWidth="1px" Font-Names="Tahoma" Font-Size="Small" Height="125px" Width="1200px" /> <RowAlternateStyleDefault BackColor="Honeydew"> </RowAlternateStyleDefault> <HeaderStyleDefault Height="25px" BackColor="#0066FF" BorderStyle="Solid" HorizontalAlign="Left" Cursor="Hand" Font-Names="Tahoma" Font-Size="Small" ForeColor="White"> <Padding Bottom="0px" Top="0px" Left="1px" Right="1px" /> <BorderDetails ColorLeft="DimGray" ColorTop="DimGray" WidthLeft="1px" WidthTop="1px" /> </HeaderStyleDefault> <RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" Cursor="Default"> <Padding Bottom="0px" Top="0px" Left="1px" Right="1px" /> <BorderDetails ColorLeft="Window" ColorTop="Window" /> </RowStyleDefault> <SelectedRowStyleDefault BackColor="LightBlue" Font-Names="Tahoma" Font-Size="Small" /> <GroupByBox Hidden="true" /> <ClientSideEvents BeforeRowDeactivateHandler="grdClients_BeforeRowDeactivateHandler" /> <ActivationObject BorderColor="" BorderWidth="" /> </DisplayLayout> <Bands> <igtbl:UltraGridBand AllowAdd="No" AllowDelete="No" AllowSorting="No" AllowUpdate="Yes" AllowColumnMoving="None"> <Columns> <igtbl:UltraGridColumn BaseColumnName="ClientId" Key="ClientId" Hidden="true" /> <igtbl:UltraGridColumn BaseColumnName="ClientTypeId" Key="ClientTypeId"> <Header Title="Type" Caption="Type" /> <Footer Title="Total:" Caption="Total:" /> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="PctOfRevenue" Key="PctOfRevenue" EditorControlID="wneClientsPctOfRevenueEditor" Type="Custom"> <Header Title="% of Revenue" Caption="% of Revenue" /> </igtbl:UltraGridColumn> <igtbl:TemplatedColumn BaseColumnName="Comments" Key="Comments"> <Header Title="Comments" Caption="Comments" /> <CellStyle TextOverflow="Ellipsis"> </CellStyle> </igtbl:TemplatedColumn> </Columns> </igtbl:UltraGridBand> </Bands> </igtbl:UltraWebGrid> <igtxt:WebNumericEdit ID="wneClientsPctOfRevenueEditor" runat="server" MaxLength="6" HorizontalAlign="Center" MinDecimalPlaces="None" MaxValue="100" MinValue="0" NullText="" CssClass="Field" BorderStyle="None" DataMode="Int" /> </td> </tr> <tr> <td style="width: 50%; text-align: right; padding: 2px;"> <asp:Label ID="lblClientRevenueTotal" runat="server" Text="Total:" /> <asp:Label ID="lblClientRevenueTotalVal" runat="server" /> </td> <td style="width: 50%; text-align: right; padding: 2px;"> <igtxt:WebImageButton ID="btnAddClient" runat="server" CausesValidation="true" Text="Add" OnClick="btnAddClient_OnClick" Height="25px" /> <igtxt:WebImageButton ID="btnDeleteClient" runat="server" CausesValidation="true" Text="Delete" OnClick="btnDeleteClient_OnClick" Height="25px" /> </td> </tr> </table> </igmisc:WebAsyncRefreshPanel> </Template></igmisc:WebGroupBox>
This function gets called each time the page is loaded, postback or not:
private void generateScripts(){ if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "DPLRatingProjectsAndClients")) { System.Text.StringBuilder sb = new System.Text.StringBuilder(2048); sb.AppendLine("function grdProjects_CellClickHandler(gridId, cellId) "); sb.AppendLine("{ "); sb.AppendLine(" var btnDeleteProject = ig_getWebControlById('" + this.btnDeleteProject.ClientID + "'); "); sb.AppendLine(" btnDeleteProject.setEnabled(true); "); sb.AppendLine(" var btnDeleteProjectElement = btnDeleteProject.getElement(); "); sb.AppendLine(" btnDeleteProjectElement.style.cursor = 'hand'; "); sb.AppendLine("} "); sb.AppendLine(" "); sb.AppendLine("function grdClients_CellClickHandler(gridId, cellId) "); sb.AppendLine("{ "); sb.AppendLine(" var btnDeleteClient = ig_getWebControlById('" + this.btnDeleteClient.ClientID + "'); "); sb.AppendLine(" btnDeleteClient.setEnabled(true); "); sb.AppendLine(" var btnDeleteClientElement = btnDeleteClient.getElement(); "); sb.AppendLine(" btnDeleteClientElement.style.cursor = 'hand'; "); sb.AppendLine("} "); if (IsEditable) { this.grdProjects.DisplayLayout.ClientSideEvents.CellClickHandler = "grdProjects_CellClickHandler"; this.grdClients.DisplayLayout.ClientSideEvents.CellClickHandler = "grdClients_CellClickHandler"; } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "DPLRatingProjectsAndClients", sb.ToString(), true); }}
Any insight you guys might have would be appreciated, however my deadline is coming up quick and I've got a lot more to do so I have no time to provide a sample project or scale everything down to just these elements. If anyone knows of anything that could help then I'm all ears, otherwise thanks anyways.
-MajorKusinagi