|
Rank: Member Groups: Member
Joined: 3/3/2008 Posts: 17
|
I am using the Grid Control and when I click on a cell it changes color, but, does not retain/display the data input into it. The two editable column are the two custom columns. One has Javascript the other does not. Neither one works.
The Javascript:
function on_begin_edit(cell) { //Get the current cell value var v = cell.getValue(); //Use index 0 if there is no value if (v == null){ v = 0; } document.getElementById('TextBox1').value = v; }
function on_end_edit(cell) { //Get the current cell value var v = cell.getValue(); if (v == 0) { v = null; } alert("Got Here"); //Return the new value to the grid return v; }
The following is the code for the Grid:
<eo:Grid ID="GridInventory" runat="server" BorderColor="Brown" BorderStyle="Groove" BorderWidth="3px" ColumnHeaderHeight="26" FixedColumnCount="5" Font-Bold="False" Font-Italic="False" Font-Names="Verdana" Font-Overline="False" Font-Size="X-Small" Font-Strikeout="False" Font-Underline="False" GridLineColor="Black" GridLines="Both" ItemHeight="19" PageSize="25" ClientSideOnItemSelected="GetGridItem" PagerLabelTemplate="" CssClass="GridStyle1" ClientSideOnCellSelected="" KeyField="InCode" ClientSideOnItemCommand="GetAddItem" FullRowMode="False" > <ItemStyles> <eo:GridItemStyleSet> <ItemStyle CssText="background-color: white" /> <AlternatingItemStyle CssText="background-color:#FFFBD6" /> <ItemHoverStyle CssText="background-color:#f7778a;background-repeat:repeat-x;" /> <SelectedStyle CssText="background-color:#d54461;background-repeat:repeat-x;" /> <EditSelectedStyle CssText="background-color:white;" /> <CellStyle CssText="padding-left:8px;padding-top:2px; color:#336699;" /> </eo:GridItemStyleSet> </ItemStyles> <ColumnTemplates> <eo:StaticColumn> </eo:StaticColumn> <eo:TextBoxColumn> </eo:TextBoxColumn> <eo:ButtonColumn> </eo:ButtonColumn> <eo:CustomColumn> </eo:CustomColumn> </ColumnTemplates> <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" /> <ColumnHeaderTextStyle CssText="background-color:brown;color:brown;" /> <Columns> <eo:RowNumberColumn DataField="InCode" HeaderText="Item" Name="Item" Width="1"> <CellStyle CssText="color:black;padding-left:10px;text-align:center;" /> </eo:RowNumberColumn> <eo:CustomColumn DataField="webqty" HeaderText="Qty" Width="60" ClientSideEndEdit="on_end_edit" Name="WebQty" ClientSideBeginEdit="on_begin_edit"> </eo:CustomColumn> <eo:StaticColumn DataField="InDescription" HeaderText="Description" Name="InDescription" Text="" Width="300"> <CellStyle CssText="color:black;padding-left:5px;" /> </eo:StaticColumn> <eo:StaticColumn DataField="InRentPrice" DataFormat="{0:C}" HeaderText="Cost" Name="Cost" Text="" Width="75"> <CellStyle CssText="color:black;font-size:X-Small;padding-right:10px;text-align:right;" /> </eo:StaticColumn> <eo:CustomColumn HeaderText="Total" Width="75" DataField="webtotal"> </eo:CustomColumn> </Columns> <ColumnHeaderStyle CssText="background-color:brown;border-bottom-color:brown;border-bottom-style:solid;border-left-color:brown;border-left-style:solid;border-right-color:brown;border-right-style:solid;border-top-color:brown;border-top-style:solid;color:white;font-weight:bold;padding-left:8px;padding-top:2px;" /> <ColumnHeaderHoverStyle CssText="background-color:brown;border-bottom-color:brown;border-bottom-style:solid;border-left-color:brown;border-left-style:solid;border-right-color:brown;border-right-style:solid;border-top-color:brown;border-top-style:solid;color:white;font-weight:bold;padding-left:8px;padding-top:2px;" /><ContentPaneStyle CssText="" /> </eo:Grid>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Your on_end_edit handler is wrong. The purpose of this function is to retrieve the value of your "editing element" (for example, your textbox) to be transferred to the Grid cell that is being edited. Your code simply returns whatever the Grid cell already has. So obviously the new value is always discarded.
|
|
Rank: Member Groups: Member
Joined: 3/3/2008 Posts: 17
|
I never see the ALERT("Got Here"). I was just testing the round trip... Values were to follow. What I am trying to do eventually is Click on a cell, enter a number, and have the cell retain that value. I checked the database and it is NOT in read only mode. Neither of the two custom columns show the entered number or keep it. According to the documention Clicking on the cell should put it into Edit mode, unless I a reading the documentation wrong. Also, I added an Alert("Got Her") to the on_begin_edit(cell) and don't get that alert either. Any help in the right direction would be appreciated...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The easiest way for you to find out why the Grid does not enter edit mode when a cell is clicked is to compare our sample with your code. It should not be too difficult to locate the difference and once you get the grid to enter edit mode, everything else should start going.
Editing with Grid has nothing to do with whether the database is in read only mode. So there is no need to look there.
Thanks
|
|
Rank: Member Groups: Member
Joined: 3/3/2008 Posts: 17
|
Great answer, really helpfull. I found that if I change the field from a Custom to a Textbox it is now editable. I do lose the ClientSideGetText and ClientSideBeginEdit and ClientSideEndEdit. So my question is:
Is there a way to use ClientSideBeginEdit etc from a TextBoxColumn?
BTW, Samples did not help. Trial and Error worked, but, that's why I asked support....
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Steve,
Tria and error always works. Sometimes sample and documentation can help a lot as well. The basic idea is, when one page works and the other doesn't, it should be quite easy to find out what triggered the problem in the non-working page by comparing those two pages (obviously also do "trial and error" on the non-working page). We generally ask our users to perform comparing/trial and error by themselves because they have the full source code of their project that demonstrates the problem.
As for whether there is a way to use ClientSideBeginEdit on a TextBoxColumn, the answer is no. The quickest way to verify this is to go to the document to check all the properties for the TextBoxColumn class --- and you won't see ClientSideBeginEdit there.
Thanks
|
|