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

Unbound Dynamic Columns AllowAddNewRow

5 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Curtis asked on 05 Jul 2018, 08:40 PM

I have a WinUI RadGridView that is completely blank - the columns are built dynamically.  I have the editing of those columns completed and working but now I have one final piece of this puzzle I cannot figure out:

 

With a blank grid (grid without columns) even when you set "mygrid.AllowAddNewRow = True" you don't get the "Click here to add new row" row - which makes perfect sense...no columns, there's nothing that can be added.

 

But once the dynamic columns have all been added, their props set - then I do the mygrid.AllowAddNewRow = True and...I still don't get the "Click here to add..."

Per usual I've spent a ton of time trying to read what I can - lots of threads posted that get close to what I'm doing but nothing like the above and I'm at my Witts End.

 

I'm guessing it has something to do with the MasterTemplate - something I'm not adding when I create the dynamic columns that is preventing this?  For this specific grid, existing data is 'read only' so as those cells are added, readonly = True but that shouldn't have anything to do with adding a new row should it?

 

Anyway, please advise!  I'm seriously stuck on this one.

 

-Curtis

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 06 Jul 2018, 06:43 AM
Hello Curtis,

This is probably because the new row is focused after the columns are added. You need to clear the current row in order to show the text:
private void radButton1_Click(object sender, EventArgs e)
{
    for (int i = 0; i < 5; i++)
    {
        radGridView1.Columns.Add("Col " + i);
    }
    radGridView1.CurrentRow = null;
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 06 Jul 2018, 07:23 PM

Thanks once again for the quick reply, Dimitar!
Here's a code snippet:
gg.BestFitColumns(BestFitColumnMode.AllCells)
gg.EndUpdate()
' And finally turn on/off the 'add row' based on user perms
gg.CurrentRow = Nothing
gg.AllowAddNewRow = g_UserGroup.HasPerm(Permissions.CLMNT_AddEditClaimantDCC)

I've checked numerous times - gg.AllowAddNewRow IS "True"
Here are several screenshots.  First one shows the grid WITHOUT the last source-line from above - there is NO .AllowAddNewRow = True anywhere for this grid.  The grid looks exactly as it should.
The second screen shot shows what the grid looks like WITH the .AllowAddNewRow = True set in the above snippet
And the third screen shows what the grid looks like if I enter some data into one of the cells...

The problem is - this specific grid is only ever supposed to have zero or one row!  So if there is no data, it should be blank but showing the 'Click here to add...' (the row - or whatever its called - created by .AllowAddNewRow = True.)  The user clicks, they get a new row, add their values...and in gg.RowsChanged I perform this test:
if gg.Rows.Count > 0 then
    gg.AllowAddNewRows = False
end if

I've put breakpoints in the above to see if it ever falls inside the If/Then...it does not - not until I type in some data and hit enter and the new row gets created. 

If this is "working as designed" I can live with it - but if it's not, I wanted to point out the issue to you folks.
Thanks again - here are the screen shots.  I'm not sure if this website adds the images in the order in which I selected so they may be reversed but I added comments to each shot so you can see which is which.

-C

 

0
Dimitar
Telerik team
answered on 09 Jul 2018, 06:47 AM
Hello Curtis,

This is not an issue, and the desired behavior can be achieved by setting the CurrentRow to Nothing. What happens is that when only the new row is visible the grid makes is current and it has the focus. When this row is focused the message will be removed and the user should start filling the data. I have attached a small example that shows how this works. 

Let me know if I can assist you further.
 
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 10 Jul 2018, 05:26 AM

Thank you Dimitar :)

That makes sense actually and I like it a lot better than the way I was trying to force the grid to act. As always, I appreciate the terrific help.

 

-Curtis

 

0
Dimitar
Telerik team
answered on 10 Jul 2018, 10:12 AM
Hello Curtis,

I am glad that this works now. Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dimitar
Telerik team
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or