This is a migrated thread and some comments may be shown as answers.

Map Tab key to Add Row

11 Answers 208 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 14 Jan 2009, 04:13 PM

Hi I need to be able to add a new row when tabbing off the last column of the last row. Is this possible?

Thanks,

Derek.

11 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 16 Jan 2009, 03:45 PM
Hello Derek,

Thank you for the questions.

There is a simple solution for this task - just set the AddNewRow position to Bottom:

this.radGridView1.MasterGridViewTemplate.AddNewRowPosition = PinnedRowPosition.Bottom; 

Hope this suits your scenario. Write me back if you have other questions.

Regards,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Derek
Top achievements
Rank 1
answered on 16 Jan 2009, 04:17 PM
Hi,
Thanks for the reply but this will just add to the bottom every time, which is fine but I would like the grid to move to a new row when on the last column of the last row. Currently the grid stays on the last column and stays there when I tab.

Thanks for your help,
Derek.
0
Derek
Top achievements
Rank 1
answered on 19 Jan 2009, 05:18 PM
Any Ideas?
0
Martin Vasilev
Telerik team
answered on 19 Jan 2009, 06:43 PM
Hello Derek,

Thank you for getting back to me.

You can implement adding new row behaviour, by using custom GridBehaviour class. You have to override ProccessTabKey method and create custom RadGridView class that implements your custom GridBehaviour . This approach was demonstrated in attached example project.

Do not hesitate to contact me again, If you need additional assistance.

Greetings,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Derek
Top achievements
Rank 1
answered on 20 Jan 2009, 01:38 PM
Hi Martin,
Thanks for the solution, however, it counts all columns rather than just the ones that are visible. Therefore the solution won't work. Is there a wa to count the visible columns?

Thanks,
Derek.
0
Derek
Top achievements
Rank 1
answered on 20 Jan 2009, 01:49 PM
Actually I got it working now thanks, but I want to restore the theme I had.   The code example does not work for me:

public

 

override string ThemeClassName

 

{

 

get

 

{

 

return typeof(RadGridView).FullName;

 

}

}

I get an error with ThemeClassName:    "Error 3 'Public Overrides ReadOnly Property ThemeClassName() As String' cannot override 'Public Overridable Property ThemeClassName() As String' because they differ by 'ReadOnly' or 'WriteOnly'. C:\development\CRM\CRM\Classes\CustomRadGridView.vb 18 40 CRM
"
and with  RadGridView:   "Error 4 'RadGridView' is a type and cannot be used as an expression. C:\development\CRM\CRM\Classes\CustomRadGridView.vb 20 33 CRM
"
Any Ideas?

Thanks

0
Derek
Top achievements
Rank 1
answered on 20 Jan 2009, 02:54 PM

Forgot to mention i tried in VB.net:

 

Public

 

Overrides ReadOnly Property ThemeClassName() As String

 

 

 

 

 

Get

 

 

 

 

 

Return Type.GetType(Telerik.WinControls.UI.RadGridView).FullName

 

 

End Get

 

 

 

 

 

End Property


and I get the two errors above.  Is this going to be a property of the radgridview in a future release?  Most other grids have it.

 

0
Accepted
Martin Vasilev
Telerik team
answered on 21 Jan 2009, 07:54 AM
Hello Derek,

Please find as attachment the same example in VB.Net which includes some custom logic about handling the case when the last columns is hidden.

If you have other questions, do not hesitate to contact me again.

Best wishes,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Derek
Top achievements
Rank 1
answered on 21 Jan 2009, 09:22 AM
That worked perfectly, thanks very much for all your help.
0
Razeen
Top achievements
Rank 1
answered on 30 Apr 2010, 05:11 PM
If the last column is Expression its throwing the following error

"Object reference not set to an instance of an object."

How can i handle this error
0
Martin Vasilev
Telerik team
answered on 05 May 2010, 08:39 PM
Hello Razeen,

Since Expression columns are read only you simply should skip them in the CheckIfLast method. For example:
private bool CheckIfLast()
{
    if (this.GridControl.CurrentCell.RowIndex == this.GridControl.RowCount - 1)
    {
        if (this.GridControl.CurrentCell.ColumnIndex == this.GridControl.ColumnCount - 1)
        {
            return true;
        }
        else
        {
            for (int i = this.GridControl.CurrentCell.ColumnIndex + 1; i < this.GridControl.ColumnCount; i++)
            {
                if (this.GridControl.Columns[i].IsVisible && String.IsNullOrEmpty(this.GridControl.Columns[i].Expression))
                {
                    return false;
                }
            }
            return true;
        }
    }
    else
    {
        return false;
    }
}

A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.


Best wishes,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Derek
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Derek
Top achievements
Rank 1
Razeen
Top achievements
Rank 1
Share this question
or