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

Completing a New Row in Unbound Mode

5 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phillip
Top achievements
Rank 1
Phillip asked on 08 Jul 2009, 11:21 AM
Hi,

Does anyone know how the user is supposed to "commit" a new row in unbound mode ? I constructed a simple project with a three column grid and ran it - I clicked on the "add new row" line and entered some data. Now what ? I cannot add another row as the "add new row" pseudo-row has disappeared. Clicking on the "pen and paper" icon on the left just switches the row icon to a "*" indicating that I'm still in new-row-edit mode. The only way I can find of actually committing my new row is to click on a column header button (even tabbing to another windows control doesn't seem to commit my new row).

I must be doing something wrong here, but I've searched the forums and pretty much every property I can find on the RadGrid but cannot do this simple thing. Must be a bad day for me <grin> . Seriously though, can anyone help with this trivial task ?

Phillip

5 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 09 Jul 2009, 09:34 AM
Hello Phillip,

You can finish the process of adding new row in several ways:

1. By clicking the Enter key.
2. By clicking the mouse buttons somewhere out of the new row.
3. By clicking the down arrow when the active editor is not date time or spin editor.
4. By clicking the right arrow or Tab key when the last column is being edited.

We will appreciate any ideas regarding RadGridView behavior in this case. I am looking forward to your reply.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Phillip
Top achievements
Rank 1
answered on 09 Jul 2009, 02:46 PM
Hi,

Thanks for the reply.

The behviour I would expect (and maybe I can get this to happen in code, if you can point me at the command to force the creation of the "new" row) would be that a fresh "click here to add new row" would appear as soon as the first Cell_BeginEdit had been called. This would mean that the user could click into a row, and as soon as they start editing the row, this is accepted as a "live" row and a fresh "click here to add new row" would be generated.

I have a particular problem with the grid as it is, because I autopopulate the data that gets put in the grid for a new record, based on some application specific algorithms - in many cases the user never actually has to edit the data I prepopulate. In this case I can easily put the focus into the first column of the grid, thereby artificially firing the Cell_BeginEdit event, which would be acceptible if the grid behaved as above.

Can you help ?
0
Jack
Telerik team
answered on 10 Jul 2009, 01:50 PM
Hi Phillip,

I understand. Currently RadGridView doesn't support this kind of behavior. You can set the MasterGridViewTemplate.AddNewRowPosition property to Bottom. This way when you press Enter the row will become active and new "add new row" row will be added at the bottom of RadGridView rows.

The behavior you want to achieve seems to be like the standard MS DataGridView. Our ambition is to make controls similar in functionality to the standard MS controls. So, we will consider implementing this behavior in one of our upcoming releases.

I hope this helps. If you have more questions, don't hesitate to write us.

 
Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Phillip
Top achievements
Rank 1
answered on 10 Jul 2009, 02:47 PM
Hi,

Thanks for the reply. Is there any way I can force the RadGridView to add a new row ? I can get the behaviour I want if I could identify which API call forced a new row add. If this is not possible, do you think I should simply add a  new row to my underlying data object, and then rebuild the grid ?

Phillip
0
Julian Benkov
Telerik team
answered on 14 Jul 2009, 01:26 PM
Hello Phillip,

You can add row to your underlying data object, but this scenario is valid only for "bound" mode. When using grid in unbound mode, you also can try the following workaround:

public partial class GridForm : Form, IMessageFilter 
    private bool createNewRow = false
    private const int WM_KEYDOWN = 0x100; 
    private const int VK_RETURN = 0x0D; 
 
    public GridForm() 
    { 
        InitializeComponent(); 
        Application.AddMessageFilter(this); 
    } 
 
    /// <summary> 
    /// Clean up any resources being used. 
    /// </summary> 
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
    protected override void Dispose(bool disposing) 
    { 
        Application.RemoveMessageFilter(this); 
 
        if (disposing && (components != null)) 
        { 
            components.Dispose(); 
        } 
        base.Dispose(disposing); 
    } 
 
    private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e) 
    { 
        if (createNewRow && e.OldRow is GridViewNewRowInfo && e.CurrentRow is GridViewDataRowInfo) 
        { 
            this.radGridView1.CurrentRow = this.radGridView1.MasterGridViewInfo.TableAddNewRow; 
            this.radGridView1.CurrentRow.Cells[0].BeginEdit(); 
            createNewRow = false
        } 
    } 
    #region IMessageFilter Members 
 
    public bool PreFilterMessage(ref Message m) 
    { 
        if (m.Msg == WM_KEYDOWN) 
        { 
            if ((int)m.WParam == VK_RETURN) 
            { 
                createNewRow = true
            } 
        } 
 
        return false
    } 
    #endregion 

Please let us know if this solves the issue.

Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Phillip
Top achievements
Rank 1
Answers by
Jack
Telerik team
Phillip
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or