Welcome Guest Search | Active Topics | Sign In | Register

custom grid column Options
Brad Coble
Posted: Thursday, January 8, 2009 6:42:11 AM
Rank: Member
Groups: Member

Joined: 12/17/2008
Posts: 16
In the code below, if you use the keyboard to move among the cells and select one to edit, the focus goes away and you have to use the mouse to reselet the cell anyway.

How can I make it stay selected?

I know that if i use the standard maskededit column it works as i expect. But that doesnt allow me to have client side before and after edit javascript functions.


Code: HTML/ASPX
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet("myds");
        ds.Tables.Add("row");
        ds.Tables["row"].Columns.Add("col1");
        ds.Tables["row"].Columns.Add("col2");
        ds.Tables["row"].Columns.Add("col3");

        for (int i = 1; i <= 29; i++)
        {
            DataRow newRow = ds.Tables["row"].NewRow();
            newRow["col1"] = i.ToString();
            newRow["col2"] = i.ToString();
            newRow["col3"] = i.ToString();
            ds.Tables["row"].Rows.Add(newRow);
        }

        Grid1.DataSource = ds;
        Grid1.DataBind();
    }
html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">
        function on_end_edit(cell) {
            var c = cell.getColumn();
            var z = "me" + c.getIndex();
            var m = eo_GetObject(z);
            var v = m.getText();
            return v;
        }

        function on_begin_edit(cell) {
            var v = cell.getValue();
            var c = cell.getColumn();
            var z = "me" + c.getIndex();
            var m = eo_GetObject(z);

            m.setText(v);
            if (m.hasFocus())
                alert(m.getId());
        }

        function on_get_text(column, item, cellValue) {
            return cellValue;
        }

        function clientside_generic_handler(sender) {
        }
        
        function test_handler(sender) {
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <eo:CallbackPanel ID="CallbackPanel1" runat="server" Triggers="{ControlID:Grid1;Parameter:}">
            <eo:Grid ID="Grid1" runat="server" BorderColor="#C7D1DF" BorderWidth="1px" ColumnHeaderAscImage="00050303"
                ColumnHeaderDescImage="00050304" ColumnHeaderDividerImage="00050302" Font-Bold="False"
                Font-Italic="False" Font-Names="Verdana" Font-Overline="False" Font-Size="9pt"
                Font-Strikeout="False" Font-Underline="False" GridLineColor="199, 209, 223" GridLines="Both"
                Height="571px" ItemHeight="19" Width="300px" FullRowMode="False" EnableKeyboardNavigation="True"
                DataTable="row" ClientSideOnCellSelected="clientside_generic_handler">
                <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
                <ItemStyles>
                    <eo:GridItemStyleSet>
                        <ItemStyle CssText="background-color: white" />
                        <ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
                        <SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
                        <CellStyle CssText="padding-left:8px;padding-top:2px; color:#336699;white-space:nowrap;" />
                    </eo:GridItemStyleSet>
                </ItemStyles>
                <ContentPaneStyle CssText="text-align: left" />
                <Columns>
                    <eo:CustomColumn ClientSideGetText="on_get_text" ClientSideBeginEdit="on_begin_edit"
                        ClientSideEndEdit="on_end_edit" DataField="col1" HeaderText="Body Number" AllowResize="False">
                        <EditorTemplate>
                            <eo:MaskedEdit runat="server" ID="me0" Width="92" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;"
                                ClientSideOnLoad="test_handler">
                                <eo:MaskedEditSegment SegmentType="Number" Text="        " />
                            </eo:MaskedEdit>
                        </EditorTemplate>
                    </eo:CustomColumn>
                    <eo:CustomColumn ClientSideGetText="on_get_text" ClientSideBeginEdit="on_begin_edit"
                        ClientSideEndEdit="on_end_edit" DataField="col2" HeaderText="Robot Code" AllowResize="False">
                        <EditorTemplate>
                            <eo:MaskedEdit runat="server" ID="me1" Width="92" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;">
                                <eo:MaskedEditSegment SegmentType="Number" Text="        " />
                            </eo:MaskedEdit>
                        </EditorTemplate>
                    </eo:CustomColumn>
                    <eo:CustomColumn ClientSideGetText="on_get_text" ClientSideBeginEdit="on_begin_edit"
                        ClientSideEndEdit="on_end_edit" DataField="col3" HeaderText="Length" AllowResize="False">
                        <EditorTemplate>
                            <eo:MaskedEdit runat="server" ID="me2" Width="92" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;">
                                <eo:MaskedEditSegment SegmentType="Number" Text="        " />
                            </eo:MaskedEdit>
                        </EditorTemplate>
                    </eo:CustomColumn>
                </Columns>
                <ColumnHeaderStyle CssText="background-image:url('00050301');padding-left:8px;padding-top:2px;font-weight: bold;color:white;" />
            </eo:Grid>
        </eo:CallbackPanel>
    </div>
    </form>
</body>
</html>
eo_support
Posted: Thursday, January 8, 2009 12:37:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

Try to change your on_begin_edit to:


Code: JavaScript
.....

var m = eo_GetObject(z);

//Get the underlying textbox
var tb = document.getElementById(m.getId());

//Delay focus the textbox. Note you can not focus
//it right away because the textbox is not visible
//yet at this point
window.setTimeout(
    function()
    {
        tb.focus();
    }, 10);

.....


Hope this helps.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.