Hi all,
I use UltraWebGrid.
I have such code
<bands> <Band ....> <RowEditTemplate> <My control .... /> </RowEditTemplate>
Now when I try to edit row I see My control template. But it disappears on attempt to scroll or click in any area (not on template window). Can I make this template to not disappear in theese cases?
Hello, Rumen!
I found the same solution (little differences from yours) and I was writing you but suddenly I got your message =)
Thank you for your job!
Hello Svetlana,
So I dug further into this and I think I have a solution that works fine. It gets a little bit more complicated than my original idea though, you will need a couple of additional changes.
1. Implement BeforeRowTemplateOpenHandler client side handler, in addition to BeforeRowTemplateCloseHandler
<ClientSideEvents BeforeRowTemplateOpenHandler="beforeRowTemplateOpen" BeforeRowTemplateCloseHandler="beforeRowTemplateClose" />
2. The javascript now becomes something similar to this:
<script type="text/javascript"> var globalCancel; function beforeRowTemplateOpen() { globalCancel = false; } function beforeRowTemplateClose(grid, row, save) { if (!save && !globalCancel) { return true; } } </script>
3. Modify the autogenerated "Cancel" button onclick event handler to:
<input id="igtbl_reCancelBtn" onclick="globalCancel=true; igtbl_gRowEditButtonClick(event);" style="width:50px;" type="button" value="Cancel"></input>
This does the trick. Here is the whole ASPX I have, for your convenience:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName] FROM [Customers]"> </asp:AccessDataSource> <igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="AccessDataSource1" Height="200px" Width="325px"> <bands> <igtbl:UltraGridBand> <Columns> <igtbl:UltraGridColumn BaseColumnName="CustomerID" IsBound="True" Key="CustomerID"> <Header Caption="CustomerID"> </Header> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="CompanyName" IsBound="True" Key="CompanyName"> <Header Caption="CompanyName"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="ContactName" IsBound="True" Key="ContactName"> <Header Caption="ContactName"> <RowLayoutColumnInfo OriginX="2" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer> </igtbl:UltraGridColumn> </Columns> <RowEditTemplate> <p align="right"> CustomerID <input id="igtbl_TextBox_0_0" columnkey="CustomerID" style="width:150px;" type="text"> <br> CompanyName <input id="igtbl_TextBox_0_1" columnkey="CompanyName" style="width:150px;" type="text"> <br> ContactName <input id="igtbl_TextBox_0_2" columnkey="ContactName" style="width:150px;" type="text"> <br> </br> </input> </br> </input> </br> </input> </p> <br> <p align="center"> <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width:50px;" type="button" value="OK"> <input id="igtbl_reCancelBtn" onclick="globalCancel=true; igtbl_gRowEditButtonClick(event);" style="width:50px;" type="button" value="Cancel"> </input> </input> </p> </br> </RowEditTemplate> <RowTemplateStyle BackColor="White" BorderColor="White" BorderStyle="Ridge"> <BorderDetails WidthBottom="3px" WidthLeft="3px" WidthRight="3px" WidthTop="3px" /> </RowTemplateStyle> <addnewrow view="NotSet" visible="NotSet"> </addnewrow> </igtbl:UltraGridBand> </bands> <displaylayout bordercollapsedefault="Separate" AllowUpdateDefault="RowTemplateOnly" name="UltraWebGrid1" rowheightdefault="20px" version="4.00"> <ClientSideEvents BeforeRowTemplateOpenHandler="beforeRowTemplateOpen" BeforeRowTemplateCloseHandler="beforeRowTemplateClose" /> <framestyle borderstyle="Solid" borderwidth="1px" font-names="Verdana" font-size="8pt" height="200px" width="325px"> </framestyle> <pager> <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <borderdetails colorleft="White" colortop="White" /> </PagerStyle> </pager> <editcellstyledefault borderstyle="None" borderwidth="0px"> </editcellstyledefault> <headerstyledefault backcolor="LightGray" borderstyle="Solid"> <borderdetails colorleft="White" colortop="White" /> </headerstyledefault> <rowstyledefault backcolor="White" bordercolor="Gray" borderstyle="Solid" borderwidth="1px" font-names="Verdana" font-size="8pt"> <padding left="3px" /> <borderdetails colorleft="White" colortop="White" /> </rowstyledefault> <addnewbox> <boxstyle backcolor="LightGray" borderstyle="Solid" borderwidth="1px"> <borderdetails colorleft="White" colortop="White" /> </boxstyle> </addnewbox> <activationobject bordercolor="" borderwidth=""> </activationobject> </displaylayout> </igtbl:UltraWebGrid> <script type="text/javascript"> var globalCancel; function beforeRowTemplateOpen() { globalCancel = false; } function beforeRowTemplateClose(grid, row, save) { if (!save && !globalCancel) { return true; } } </script>
Thank you very much for your answer!
No, it's not possible to remove button "Close". I would like it to work )
Thanks for writing. I played a bit with your scenario, but unfortunately I do not seem to find any easy solution for this one (e.g. property setting). The closest I could get to this was using the BeforeRowTemplateCloseHandler client side event handler documented here:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebGrid_Client_Side_Events_CSOM.html
For example:
<ClientSideEvents BeforeRowTemplateCloseHandler="beforeRowTemplateClose" />
and then in the event handler, do something like this:
<script type="text/javascript"> function beforeRowTemplateClose(grid, row, save) { if (!save) { return true; } } </script>
This successfully prevents the window from closing on scroll or click outside the window and closes it only on pressing "OK". However, there is one side effect - the row template is not closed on pressing "Close" as well. Is it possible to remove the "Close" button in your scenario (by simply removing it from the autogenerated RowEditTemplate)?
I will try digging into this, but this is what I was able to do so far.