Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
660
TemplateAddRowPrompt collides with InitializeTemplateAddRow
posted

Having a Grid with a Fixed AddRow at the top.

I set the AddRowPrompt to something the user understands, like:

this.dfgrid1.DisplayLayout.Override.TemplateAddRowPrompt = "click here to add something new";

This works and looks fine. Only the Prompt is displayed in that first Grid-Line and if the user clicks, that prompt goes away.

NOW i like to preset the cell values of the AddRow, so that the user only needs to override values that doesn't fit. 
the Goal is:
- The User should click on that AddPrompt to get a new line that is prefilled with values, tab thru / correct values - finished.

I thought, the event "InitializeTemplateAddRow" could be a good idea so i did this:

this.dfgrid1.InitializeTemplateAddRow += dfgrid1_InitializeTemplateAddRow;

void dfgrid1_InitializeTemplateAddRow(object sender, InitializeTemplateAddRowEventArgs e)
        {
           
            e.TemplateAddRow.Cells["Bezeichnung"].Value = "Neue Wiedervorlage";
            e.TemplateAddRow.Cells["An"].Value = "Grote, Gunnar";
            
            DateTime dt = new DateTime(2015, 02,20, 00, 00, 00);
            e.TemplateAddRow.Cells["Datum"].Value = dt;
 
            e.TemplateAddRow.Cells["Status"].Value = "offen";
        }

well - technically this works, the cells are preset but there are 2 problems:
1.) This Initialization is running when the grid is initialized - Not when the user clicks on the AddRowPrompt to start editing. This means: Now i have prefilled Cells, overlayed with the AddRowPrompt - looking very horribly / unreadably :)
2.) If the user just Tabs thru the new Row (because every preset values fits perfectly), no new Row is beeing added (i think because the Grid didn't noticed any change event?)

Any ideas to make it look better? (preset cell values only after the user clicks on the addRow - or after the user adds the row (enter / tab on last field) and is getting on the first cell again)

Any ideas how to make the Grid add the row even if the user didn't overwrite the preset values?