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

New Row Position

2 Answers 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deepak Rao
Top achievements
Rank 1
Deepak Rao asked on 29 Mar 2010, 03:12 PM
If I set the

 

 

MasterGridViewTemplate.AddNewRowPosition =

PinnedRowPosition.Top, then the Value changing event does not fire. It fires only if it is set to bottom... Please advise


Thanks
Deepak

 

2 Answers, 1 is accepted

Sort by
0
Mathieu Yargeau
Top achievements
Rank 1
answered on 29 Mar 2010, 03:47 PM
Hello,

AddNewRowPosition's Value is Top by default. So if the value is equal to Top and you set it to Top, I'm pretty sure the event won't fire because the value wasn't changed, even is you specified a new value (since the new value is the same as the old value).

If you set the value to Bottom and then set it again to Top, the event should fire successfully twice.
0
Svett
Telerik team
answered on 01 Apr 2010, 12:20 PM
Hi Mathieu,

Thank you for your question.

I have tried to reproduce the issue using the following code snippet:
public partial class GridForm : Form
{
    public GridForm()
    {
        InitializeComponent();
 
        this.radGridView.ValueChanging += new ValueChangingEventHandler(radGridView_ValueChanging);
    }
 
    private void radGridView_ValueChanging(object sender, ValueChangingEventArgs e)
    {
        Debug.WriteLine("ValueChanging");
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        DataTable dataSource = new DataTable("sample");
        dataSource.Columns.Add("ID", typeof(int));
        dataSource.Columns.Add("Name", typeof(string));
 
        const int rowsCount = 100;
         
        for (int i = 1; i <= rowsCount; i++)
        {
            dataSource.Rows.Add(i, "Row No." + i);
        }
 
        dataSource.AcceptChanges();
 
        this.radGridView.DataSource = dataSource;
        this.radGridView.MasterGridViewTemplate.AddNewRowPosition = PinnedRowPosition.Top;
    }
}

I found out that when you are editing GridSpinEditor, the ValueChanging event is not fired. Can you give us more details the editor types where the issue occurs? Also, could you please modify the code snippet above to reproduce the issue?

If the issue appears only in GridSpinEditor, you can create a custom spin editor which resolves the issue. You can use the following code snippet:
public class MyGridSpinEditor : GridSpinEditor
{
    public override void BeginEdit()
    {
        base.BeginEdit();
 
        RadSpinElement spinElement = (RadSpinElement)this.EditorElement;
        spinElement.TextBoxItem.TextChanging += new TextChangingEventHandler(spinElement_TextChanging);
    }
 
    public override bool EndEdit()
    {
        RadSpinElement spinElement = (RadSpinElement)this.EditorElement;
        spinElement.TextBoxItem.TextChanging -= new TextChangingEventHandler(spinElement_TextChanging);
        return base.EndEdit();
    }
 
    private void spinElement_TextChanging(object sender, TextChangingEventArgs e)
    {
        RadSpinElement spinElement = (RadSpinElement)this.EditorElement;
        spinElement.Validate();
    }
}

You need to subscribe to the EditorRequired event to replace the default editor with the custom editor.
private void radGridView_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(GridSpinEditor))
    {
        e.EditorType = typeof(MyGridSpinEditor);
    }
}

If you have further questions, feel free to write back.

Regards,
Svett
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
Deepak Rao
Top achievements
Rank 1
Answers by
Mathieu Yargeau
Top achievements
Rank 1
Svett
Telerik team
Share this question
or