Welcome Guest Search | Active Topics | Sign In | Register

Not selectable rows Options
Camarate
Posted: Friday, September 3, 2010 7:32:12 AM
Rank: Advanced Member
Groups: Member

Joined: 9/2/2010
Posts: 120
Hi,

See the Grid object example below (ignore the content because it is in Portuguese):



Only the green rows may be edited. How do I do to not allow the user to select the blue line when they click the mouse over it?

Thanks, Camarate
eo_support
Posted: Friday, September 3, 2010 11:04:56 AM
Rank: Administration
Groups: Administration

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

You would set those rows to use a different "StyleSet" so that for those rows, the selected style and normal style are the same. That way the rows can still be "selected", but they will not be highlighted so that visually they do not look selected at all.

To set rows to use different StyleSet, you would use conditional formatting based on rows. See here for a working example:

http://demo.essentialobjects.com/Demos/Grid/Features/Conditional%20Formatting/Demo.aspx

Thanks!
Camarate
Posted: Friday, September 3, 2010 11:53:48 AM
Rank: Advanced Member
Groups: Member

Joined: 9/2/2010
Posts: 120
Hi,

Thanks for your reply. I'm thinking in another solution.

If in a Javascript function I could change the selected item, I could put an invisible column with a flag. When the user clicks on a row, a function would be run by OnItemSelected, and check the flag and if necessary, increments the index until an item that can be selected.

This is possible?

Regards, Camarate
eo_support
Posted: Friday, September 3, 2010 3:29:38 PM
Rank: Administration
Groups: Administration

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

Yes. You can do that by calling this function:

http://doc.essentialobjects.com/library/1/jsdoc.public.grid.selectitem.aspx

Thanks!
Camarate
Posted: Friday, September 3, 2010 4:13:52 PM
Rank: Advanced Member
Groups: Member

Joined: 9/2/2010
Posts: 120
Hi,

The idea was OK. Thanks so much for your suggestion.

I'm put the Javascript function below to others that need the same functionality.

Code: JavaScript
function OnItemSelected(grid)
{
    var item = grid.getSelectedItem();
	    
    var cell = item.getCell(1);

    while (cell.getValue() == 0)
    {
        grid.selectItem(item.getIndex() + 1);
        item = grid.getSelectedItem();
        cell = item.getCell(1);
    }
}


Put the function name in the grid parameter CientSideOnItemSelected, and in my example, I created a column with index 1 that is a flag. When equal 0 the row is non-selectable. When equal 1 the row is selectable. In my case I do not be worry because will always have a selectable row after a non-selectable.

Regards, Camarate
eo_support
Posted: Friday, September 3, 2010 5:02:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Thanks for sharing!


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.