I have a grid where I would like to have an add button for the child rows on Band 1 but not have one for the parent record (Band (0)). I have added the code below:
UG1.DisplayLayout.Bands(0).AllowAdd = Infragistics.WebUI.UltraWebGrid.AllowAddNew.No
UG1.DisplayLayout.Bands(0).AddButtonCaption = ""
UG1.DisplayLayout.Bands(1).AddButtonCaption = ""
The problem is that the first button still appears but inactive. How do I not show it at all?
Hi, let me take a look at this. I don't think there are any intrinsic property settings to accomplish this, however, we may have to take the approach of getting into the DOM and somehow hiding the button element that you are looking for.
Hi, it is me again,
I got this to work. Handle the WebGrid control's Client Side "InitializeLayoutHandler" event.
Try this code:
In Java-Script:
function UltraWebGrid1_InitializeLayoutHandler(gridName){
var x = document.getElementById(gridName + '_an_0');
// This is the ID that we want: 'UltraWebGrid1_an_0'
x.style.visibility='hidden';
}
Note how the Button Element's client side ID is constructed:
'UltraWebGrid1_an_0'
'UltraWebGrid1 = This is the ID of the WebGrid
an = This means "Add New" to represent the Add New Button
0 = This means "Band 0". You should be able to replace this portion of the ID with the number that represents your band's index.
Please note that you do not want to hard code the entire ID into your Java Script. This is the reason why we use the InitializeLayoutHandler and use the parameter that is passed (gridName) so that we let the control give us its ID rather than hard coding it ourselves. The ID changes as we add web controls to other containers like Tabs, UserControls and other containers.