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
235
Unable to Add Row...AND MORE!!!
posted

I am upgrading from 10.3 to 14.2, and in this example especially, from an UltraWebGrid to a WebHierarchicalDataGrid. I am using Visual Studio 2010 with VB.Net and ASP.Net website. This is a "two level" grid and I want to allow users (of specific permissions) to add rows to specific sections. I will explain the old way of what we were doing and where I am with the new way. (Note: Please understand that there are multiple developers on this project and I was not on the team when 10.3 was implemented, so why some things were done some ways I am not sure.)

Old Way
Across the top we have five buttons, one of them being "New". On Page_Load, the click function of this button would be set to "AddRow". Following is the AddRow function:

    var parentRow;
    function AddNew(oButton, oEvent)
    {
        var readOnly = 0;

        try
        {
            var row = igtbl_getActiveRow("<% response="" write="" wdgadmin="" clientid="">");
            var pRow = igtbl_getParentRow("<% response="" write="" wdgadmin="" clientid="">", row.Element);

            if (pRow==null)
            {
                //alert("pRow=null");
                pRow=row.Element;
                myRow=igtbl_getRowById(pRow.id);
                parentRow=myRow;
            }
            else
            {
                //alert ("getting row");
                //myRow=igtbl_getRowById(row.Element.id);
                myRow=parentRow;
            }

            readOnly=myRow.getCell(0).getValue();

            if (readOnly > 0)
            {
                //alert ("trying to insert");
                igtbl_addNew("<% response="" write="" wdgadmin="" clientid="">", 1);
                //alert ("Inserted");
                igtbl_EnterEditMode("<% response="" write="" wdgadmin="" clientid="">");

            }
            oEvent.cancel = true;
        }
        catch(ex)
        {
            alert("Select the appropriate category before clicking new");
        }
    }

Looking at this forum post, it appears that there is a much simpler way for single level grids, but I am curious as to how I can manipulate it for a multi-level grid.

Suggested New Way (Single Level Grid)
    function AddNewRow()
    {
        var grid = $find("wdgAdmin");
        var row = new Array(grid.get_rows().length, "Name", "Description");
        grid.get_rows().add(row);
    }

In the markup in the old way, there was nothing that specified anything for adding a new row. It was all done in the code behind. However, I believe there are things I need to do in the new grid in the markup. Here's what it looks like.

New Markup
    <igwdg:WebHierarchicalDataGrid ID="wdgAdmin" ClientIDMode="Static" OnRowAdded="wdgAdmin_RowAdded" runat="server" InitialDataBindDepth="0" AutoGenerateBands="true" AutoGenerateColumns="false" DataKeyFields="Permissions">
        <Columns>
            <igwdg:BoundDataField Key="Permissions" DataFieldName="Permissions" DataType="System.Int64" Hidden="true">
                <Header Text="Permissions" Tooltip="Permissions" />
            </igwdg:BoundDataField>
            <igwdg:BoundDataField Key="OrgOfficeSectionId" DataFieldName="OrgOfficeSectionId" DataType="System.Decimal" Hidden="true">
                <Header Text="OrgOfficeSectionId" Tooltip="OrgOfficeSectionId" />
            </igwdg:BoundDataField>
            <igwdg:BoundDataField Key="SectionID" DataFieldName="SectionID" DataType="System.Decimal" Hidden="True">
                <Header Text="SectionID" Tooltip="SectionID" />
            </igwdg:BoundDataField>
            <igwdg:BoundDataField Key="OfficeId" DataFieldName="OfficeId" DataType="System.Decimal" Hidden="True">
                <Header Text="OfficeId" Tooltip="OfficeId" />
            </igwdg:BoundDataField>
            <igwdg:BoundDataField Key="OrgId" DataFieldName="OrgId" DataType="System.Decimal" Hidden="True">
                <Header Text="OrgId" Tooltip="OrgId" />
            </igwdg:BoundDataField>
            <igwdg:BoundDataField Key="Header" DataFieldName="Header" Width="784px">
                <Header Text="Category" Tooltip="Category" />
            </igwdg:BoundDataField>
        </Columns>
        <Behaviors>
            <igwdg:Sorting Enabled="false"></igwdg:Sorting>
            <igwdg:EditingCore>
                <Behaviors>
                    <igwdg:RowAdding Enabled="false"></igwdg:RowAdding>
                    <igwdg:RowEditing Enabled="false"></igwdg:RowEditing>
                    <igwdg:RowDeleting Enabled="false"></igwdg:RowDeleting>
                </Behaviors>
            </igwdg:EditingCore>
        </Behaviors>
        <Bands>
            <igwdg:Band DataMember="Item" Key="Item" DataKeyFields="Permissions" AutoGenerateColumns="false">
                <Columns>
                    <igwdg:BoundDataField Key="Permissions" DataFieldName="Permissions" DataType="System.Int64" Hidden="True">
                        <Header Text="Permissions" Tooltip="Permissions" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="SectionId" DataFieldName="SectionId" DataType="System.Decimal" Hidden="True" Width="30px">
                        <Header Text="SectionId" Tooltip="SectionId" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="ItemId" DataFieldName="ItemId" DataType="System.Decimal" Hidden="True" Width="30px">
                        <Header Text="ItemId" Tooltip="ItemId" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="OfficeId" DataFieldName="OfficeId" DataType="System.Decimal" Hidden="True" Width="30px">
                        <Header Text="OfficeId" Tooltip="OfficeId" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="OrgId" DataFieldName="OrgId" DataType="System.Decimal" Hidden="True" Width="30px">
                        <Header Text="OrgId" Tooltip="OrgId" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="ItemName" DataFieldName="ItemName" Width="130px" HtmlEncode="true">
                        <Header Text="Name" Tooltip="Name" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="Item" DataFieldName="Item" Width="600px" HtmlEncode="true" EnableMultiline="true">
                        <Header Text="Description" Tooltip="Description" />
                    </igwdg:BoundDataField>
                    <igwdg:BoundDataField Key="OfficeCode" DataFieldName="OfficeCode" Hidden="True">
                        <Header Text="OfficeCode" Tooltip="OfficeCode" />
                    </igwdg:BoundDataField>
                </Columns>
                <Behaviors>
                    <igwdg:EditingCore Enabled="true" AutoCRUD="false">
                        <Behaviors>
                            <igwdg:RowAdding Enabled="true" Alignment="Top"></igwdg:RowAdding>
                            <igwdg:RowEditing Enabled="true"></igwdg:RowEditing>
                            <igwdg:RowDeleting Enabled="true"></igwdg:RowDeleting>
                            <igwdg:CellEditing Enabled="true">
                                <ColumnSettings>
                                    <igwdg:EditingColumnSetting ColumnKey="ItemName" />
                                    <igwdg:EditingColumnSetting ColumnKey="Item" />
                                </ColumnSettings>
                            </igwdg:CellEditing>
                        </Behaviors>
                    </igwdg:EditingCore>
                    <igwdg:Sorting Enabled="true" SortingMode="Single">
                        <ColumnSettings>
                            <igwdg:SortingColumnSetting ColumnKey="ItemName" Sortable="true" />
                        </ColumnSettings>
                    </igwdg:Sorting>
                </Behaviors>
                <Bands>
                    <igwdg:Band DataMember="Response" Key="Response" DataKeyFields="ResponseID" AutoGenerateColumns="false">
                        <Columns>
                            <igwdg:BoundDataField Key="ResponseID" DataFieldName="ResponseID" DataType="System.Decimal" Hidden="True">
                                <Header Text="ResponseID" Tooltip="ResponseID" />
                            </igwdg:BoundDataField>
                            <igwdg:BoundDataField Key="ItemId" DataFieldName="ItemId" DataType="System.Decimal" Hidden="True">
                                <Header Text="ItemId" Tooltip="ItemId" />
                            </igwdg:BoundDataField>
                            <igwdg:BoundDataField Key="ResponseCode" DataFieldName="ResponseCode">
                                <Header Text="ResponseCode" Tooltip="ResponseCode" />
                            </igwdg:BoundDataField>
                            <igwdg:BoundDataField Key="Response" DataFieldName="Response">
                                <Header Text="Response" Tooltip="Response" />
                            </igwdg:BoundDataField>
                            <igwdg:BoundDataField Key="ResponseOrder" DataFieldName="ResponseOrder" DataType="System.Decimal" Hidden="True">
                                <Header Text="ResponseOrder" Tooltip="ResponseOrder" />
                            </igwdg:BoundDataField>
                            <igwdg:BoundDataField Key="Permissions" DataFieldName="Permissions" DataType="System.SByte" Hidden="True">
                                <Header Text="Permissions" Tooltip="Permissions" />
                            </igwdg:BoundDataField>
                        </Columns>
                        <Behaviors>
                            <igwdg:EditingCore>
                                <Behaviors>
                                    <igwdg:RowAdding Enabled="true"></igwdg:RowAdding>
                                </Behaviors>
                            </igwdg:EditingCore>
                        </Behaviors>
                    </igwdg:Band>
                </Bands>
            </igwdg:Band>
        </Bands>
    </igwdg:WebHierarchicalDataGrid>

There was a private Sub called wdgAdmin_AddRowBatch that handled wdgAdmin.AddRowBatch. In there, it would determine if the record was a duplicate, remove it if it was, create the new record if it wasn't and then updated the dataset. I have now changed that to wdgAdmin_RowAdded to handle wdgAdmin.RowAdded (had to change Sub level to Protected as Private gave an error of it not being defined).

So I can click in the cells that show for a new row, but when I hit Enter, it doesn't hit my code behind, and I can't figure out why.

Other issues I'm having include:

1. Unable to edit any row but the first one. When I click in the cells for the first child row, they show as editable. However, none of the other 50 rows in that band allow me to do the same. Why is it only allowing the first row to be updated?

2. I can expand the first row, but not all rows expand. In this specific example, I have three rows, two have "+" to expand them; the first and the third. The first row expands, but the third does not. With other values queried, I've had all three rows with the "+". Two of them expanded (first and third), but the second one wouldn't.

I know an upgrade from 10.3 to 14.2 and UltraWebGrid to WebHierarchicalDataGrid is not going to be straight forward. I have a lot of code behind issues as well (attributes and functions that are no longer available and no documentation that shows a 1-to-1 relationship or applicable workaround), but I'll save those for another day. For this grid, it is databound on Page_Load as we have DALs that are pulling specific datasets and no Data Source Object I've found adequately translates. The dataset has 5 tables but only two are being used in this grid.

Please let me know if you are able to help with any or all of these issues. I truly appreciate it. Thanks.

Parents Reply Children
No Data