WebGrid 7 - Add New Row Client Side without a datasource

2 replies. Last post: July 11, 2011 11:28 PM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

 I am trying to use the grid with out a datasource as i do not need to write the information in the grid to the database, I have added rows with out any problems using server side code and it does what i need, but i have a problem when i try to add a new row clientside(javascript)
 the row gets created and the information gets writen to the cells BUT the row doesnt show in the grid.

 

////////////////////// Add New Row Code client side//////////////////////////
Row = Grid.RootTable.NewRow();

 Cells = Row.GetCells();

Cells.GetNamedItem("Operative_Name").SetText("a name would go here");       


Grid.RootTable.AddRow(Row);


//////////////////////////////////////
/////////////////////////////////////Server Side this works///////////////////////
  Dim GridRow As ISNet.WebUI.WebGrid.WebGridRow
         Dim Cell As ISNet.WebUI.WebGrid.WebGridCell

   GridRow = GridOperatives.RootTable.CreateRow()

                'Lets set the values
                GridRow.Cells.GetNamedItem("Operative_Seq").Text = fncnGET(DR("Operative_Seq"))
                GridRow.Cells.GetNamedItem("Quote_Seq").Text = Quote_Seq
                GridRow.Cells.GetNamedItem("Operative_Name").Text = fncnGET(DR("Operative_Name"))
                GridRow.Cells.GetNamedItem("Operative_Age").Text = fncnGET(DR("Operative_Age"))
                GridRow.Cells.GetNamedItem("Operative_Experience").Text = fncnGET(DR("Operative_Experience"))
                GridRow.Cells.GetNamedItem("Operative_All_Risks").Value = fncnGET(DR("Operative_All_Risks"))

                'Lets add the row
                GridOperatives.RootTable.Rows.Add(GridRow)

///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////GRID/////////////////////////////////////////

<ISWebGrid:WebGrid ID="GridOperatives" runat="server" Height="130px" UseDefaultStyle="True"
                                            Width="670px" DefaultStyleMode="Win7" BindingOperationMode="ClientBinding" OnAddRow="GridOperatives_AddRow">
                                            <LayoutSettings AllowColumnSizing="No" AllowContextMenu="False" GridLineColor="221, 236, 254"
                                                StatusBarVisible="False" AlternatingColors="False" AutoFitColumnsBuffering="False"
                                                AutoFitColumns="True" AllowEdit="Yes" AutoColMinWidth="0" >
                                                <EditFocusCellStyle BackColor="#E9CD82">
                                                </EditFocusCellStyle>
                                                <EditTextboxStyle BorderStyle="None" BorderWidth="0px" Font-Names="Verdana" Font-Size="8pt">
                                                </EditTextboxStyle>
                                                <ClientSideEvents OnRowSelect="GridSortOutButtons()" />
                                                <FrameStyle OverflowX="hidden" BackColor="white" BorderColor="#6699FF" BorderStyle="Solid"
                                                    BorderWidth="1px">
                                                </FrameStyle>
                                                <GroupByBox>
                                                    <Style BackColor="#B2CDF7" BorderColor="Peru" BorderWidth="1px">
                                                       
                                                    </Style>
                                                    <LabelStyle BackColor="White" BorderColor="Navy" BorderStyle="Solid" BorderWidth="1px"
                                                        Font-Names="Verdana" Font-Size="8pt" ForeColor="Navy" />
                                                </GroupByBox>
                                                <GroupRowInfoStyle BackColor="#F1EFE2" BackgroundImage="/CommonLibrary/Images/ColBk.gif"
                                                    BorderColor="Black" BorderStyle="None" BorderWidth="1px" CustomRules="border-bottom: #73A1E4 1px solid"
                                                    Font-Names="Verdana" Font-Size="8pt">
                                                </GroupRowInfoStyle>
                                                <AlternatingRowStyle BackColor="#DDECFE" Font-Names="Verdana" Font-Size="8pt" ForeColor="#404040" />
                                                <FocusCellStyle BorderColor="0, 45, 150" BorderStyle="Solid" BorderWidth="1px" />
                                                <RowStyle BackColor="White" CustomRules="text-overflow:hidden; overflow-x: hidden"
                                                    Font-Names="Verdana" Font-Size="8pt" ForeColor="#404040" />
                                                <SelectedRowStyle BackColor="#BDD4F4" ForeColor="Black" />
                                                <FooterStyle BackColor="PeachPuff" ForeColor="Navy" OverflowX="Hidden" />
                                                <NewRowStyle BackColor="White" Font-Names="Verdana" Font-Size="8pt" ForeColor="DarkGray">
                                                </NewRowStyle>
                                                <StatusBarStyle BackColor="#DDECFE" BorderColor="#73A1E4" BorderStyle="Solid" BorderWidth="1px"
                                                    CustomRules="border-bottom-width: 0px" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black">
                                                    <Padding Bottom="2px" Left="2px" Right="2px" Top="2px" />
                                                </StatusBarStyle>
                                                <StatusBarCommandStyle>
                                                    <Normal>
                                                        <Padding Bottom="1px" Left="1px" Right="1px" Top="1px" />
                                                    </Normal>
                                                    <Over BackColor="#FBE9B8" BorderColor="#002D96" BorderStyle="Solid" BorderWidth="1px">
                                                    </Over>
                                                    <Active BackColor="RoyalBlue" BaseStyle="Over">
                                                    </Active>
                                                </StatusBarCommandStyle>
                                                <BatchUpdateSettings AllowUndoChanges="False" AutomaticObjectUpdate="False"
                                                    PromptOnUndoAllChanges="False" />
                                            </LayoutSettings>
                                            <RootTable DataKeyField="Operative_Seq">
                                                <Columns>
                                                    <ISWebGrid:WebGridColumn Bound="False" Caption="Seq" DataType="System.Int64" Name="Operative_Seq"
                                                        Visible="false" Width="100px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt">
                                                            <Padding Left="5px" /> </CellStyle>
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="False" DataType="System.Int64" Name="Quote_Seq" Visible="false"
                                                        Width="100px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt">
                                                            <Padding Left="5px" /> </CellStyle>
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="False" Caption="Name" Name="Operative_Name" Width="400px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt" HorizontalAlign="Left">
                                                            <Padding Left="5px" /> </CellStyle>
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="True" Caption="Age" DataType="System.int64" Name="Operative_Age"
                                                        Width="45px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt" HorizontalAlign="Center">
                                                            <Padding Left="5px" /> </CellStyle>
                                                        <HeaderStyle HorizontalAlign="Center" />
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="True" Caption="Experience" DataType="System.Int64"
                                                        Name="Operative_Experience" Width="75px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt" HorizontalAlign="Center">
                                                            <Padding Left="5px" /> </CellStyle>
                                                            <HeaderStyle HorizontalAlign="Center" />
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="True" Name="Operative_PL_Limit" Visible="false"
                                                        Width="75px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt">
                                                            <Padding Left="5px" /> </CellStyle>
                                                            <HeaderStyle HorizontalAlign="Center" />
                                                    </ISWebGrid:WebGridColumn>
                                                    <ISWebGrid:WebGridColumn Bound="True" Caption="All Risks" ColumnType="CheckBox" EditType="NoEdit"
                                                        DataType="System.Boolean"  Name="Operative_All_Risks" Width="100px">
                                                        <CellStyle Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden" Font-Names="Verdana"
                                                            Font-Size="8pt" HorizontalAlign="Center">
                                                            <Padding Left="5px" /> </CellStyle>
                                                            <HeaderStyle HorizontalAlign="Center" />
                                                    </ISWebGrid:WebGridColumn>
                                                </Columns>
                                            </RootTable>
                                            <ClientBindingSettings DataSourceType="ClientDataSource"
                                                FetchDataOnPageLoad="False">
                                            </ClientBindingSettings>
                                        </ISWebGrid:WebGrid>


All times are GMT -5. The time now is 7:01 PM.
Previous Next