Welcome Guest Search | Active Topics | Sign In | Register

Grid Control - Control Cell Editing Options
Yaja
Posted: Saturday, March 13, 2010 10:13:05 PM
Rank: Newbie
Groups: Member

Joined: 3/13/2010
Posts: 3
Hello,
I recently downloaded EO.Web Controls for ASP.NET for evaluation. It is a very impressive control and it almost looks like it is the control I require. The Excel like editing capability, key navigation and customizing cell level sytle is exactly what I require. However, there is one more feature that is critical for me - it is controlling editing at the cell level. Depending on certain conditions, I would like to prevent a cell (containing either a textbox or a check box or potentially even a drop down list) from being editable. Is it possible for me to do this with the grid control? I was able to get a small demo project running with most of the things worked out, but I am unable to figure out how to prevent a cell from being editable. Is it possible to control editing at the cell level vs at the column level?
eo_support
Posted: Monday, March 15, 2010 9:45:44 AM
Rank: Administration
Groups: Administration

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

If your Grid's FullRowMode is true, you can do that by handling ClientSideBeforeEditItem and return false from your handler. It will be something like this:

Code: HTML/ASPX
<eo:Grid ClientSideBeforeEditItem="edit_item_handler" .....>
     <Columns>
          .....
          <eo:Text
          .....       
     eo:Grid>


Code: JavaScript
function edit_item_handler()
{
     return false;
}


If your FullRowMode is false, then you can handle the column's ClientSideBeginEdit handler and returns false from your handler:

Code: HTML/ASPX
<eo:Grid .....>
     <Columns>
          .....
          <eo:TextBoxColumn 
             ClientSideBeginEdit="column_edit_handler" ....>
          </eo:TextBoxColumn>
          .....       
     </Columns>
</eo:Grid>


Code: JavaScript
function column_edit_handler()
{
    return false;
}


Hope this helps.

Thanks!
Yaja
Posted: Monday, March 15, 2010 5:18:00 PM
Rank: Newbie
Groups: Member

Joined: 3/13/2010
Posts: 3
Thanks - this works for a text box. Is there something similar for a check box column as well? I couldn't get this working for a checkboxcolumn. Here is my code in the code behind file:

Code: C#
if (dc.ColumnName.ToUpper().Equals("PUSH"))
                {
                    gc = new CheckBoxColumn();
                }
                else
                {
                    gc = new TextBoxColumn();
                }
                gc.ReadOnly = false;
                eogrdData.Columns.Add(gc);
                gc.HeaderText = dc.ColumnName;
                gc.ReadOnly = false;
                gc.ClientSideBeginEdit = "column_cell_begin_edit";

And here is my javascript code (column 3 is the checkbox column):
Code: JavaScript
function column_cell_begin_edit(cell) {
            var colIndex = cell.getColIndex();
            var itemIndex = cell.getItemIndex();
            alert('ColIndex: ' + colIndex + '     ItemIndex: ' + itemIndex);
            if (colIndex == 3 || colIndex == 5) {
                if (itemIndex == 2 || itemIndex == 4 || itemIndex == 6) {
                    alert('This cell is disabled');
                    return false;
                }
            }
            return true;
        }

Any help is appreciated.

Thanks in advance.
eo_support
Posted: Monday, March 15, 2010 5:27:17 PM
Rank: Administration
Groups: Administration

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

CheckBox requires slightly different code. Here is the sample code:

http://www.essentialobjects.com/forum/postst4372_how-to-disable-checkbox.aspx

Please let us know if you still have any questions.

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.