Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
185 views

Hi

I try to trigger html5 validation inside a telerik:RedGrid and grid itself is inside telerik:RadAjaxPanel  without luck. Here is a sample of the code:

 As you can see from the sample code I provided at the end of the page that I am using <FormTemplate> to customize the form inside the grid on update and insert command, so I tried a workaround to trigger the validation via javascript by writing a hidden submit button

<input type="submit" style="display: none" name="submitButton" id="submitButton" /> and click it with javascript when ajax request started. And that did the trick with trigging the validation of html5 but a faced a new problem with firing the updated and insert command twice.  

I hope that I explain the problem well enough.

 

Here is the sample of my code:

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Html5Asp" Namespace="Html5Asp" TagPrefix="cc1" %>
<div id="period">
    <h1>Period time</h1>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server">
        <telerik:RadGrid ID="RadGrid_period" runat="server" AllowMultiRowSelection="true"
            Width="350px"
            OnNeedDataSource="RadGrid_period_NeedDataSource"
            AllowPaging="true" AllowSorting="true" PageSize="3" ImagesPath="../Images/Telerik/Grid"
            OnInsertCommand="RadGrid_period_InsertCommand"
            OnUpdateCommand="RadGrid_period_UpdateCommand"
            OnDeleteCommand="RadGrid_period_DeleteCommand">
            <PagerStyle NextPageText="&gt;" PrevPageText="&lt;" Mode="NextPrevAndNumeric"
                PagerTextFormat="Change page: {4}  |  page {0} of {1}, number of periods: {5}." />
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
            <MasterTableView DataKeyNames="Id" AutoGenerateColumns="false"
                CommandItemDisplay="Top" EditMode="EditForms">
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                    <FormTableStyle CellPadding="2" CellSpacing="0" BackColor="White" Height="110px"></FormTableStyle>
                    <FormMainTableStyle CellPadding="3" CellSpacing="0" GridLines="Horizontal" BackColor="White"
                        Height="50px" Width="100%"></FormMainTableStyle>
                    <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle>
                </EditFormSettings>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Opdater"
                        UniqueName="EditCommandColumn">
                        <HeaderStyle Width="30px" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn Text="Slet" DataTextField="username" CommandName="Delete" UniqueName="DeleteColumn"
                        ButtonType="ImageButton" ItemStyle-Width="30px"
                        ConfirmText="Do you want to remove the period ?">
                        <ItemStyle Width="30px"></ItemStyle>
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn HeaderText="id" DataType="System.int16" Display="false"
                        DataField="Id" UniqueName="Id" Visible="false" />
                    <telerik:GridBoundColumn HeaderText="name" DataType="System.String" Display="true"
                        DataField="Name" UniqueName="Name" Visible="true" />
                    <telerik:GridBoundColumn HeaderText="from time" DataType="System.TimeSpan" Display="true"
                        DataField="FromTime" UniqueName="FromTime" Visible="true" />
                    <telerik:GridBoundColumn HeaderText="to time" DataType="System.TimeSpan" Display="true"
                        DataField="ToTime" UniqueName="ToTime" Visible="true" />
                     <telerik:GridBoundColumn HeaderText="hoursPrMonth" DataType="System.int16" Display="false"
                        DataField="HoursPrMonth" UniqueName="HoursPrMonth" Visible="true" />
                </Columns>
                <EditFormSettings EditFormType="Template" ColumnNumber="1" CaptionDataField="name"
                    CaptionFormatString="Change period name,from time and to time for period: {0}">
                    <FormTemplate>
                        <div class="hidRowId">
                            <label>id</label>
                            <cc1:TextInput ID="TextInput1" runat="server" Text='<%# Bind("Id") %>' IsReadOnly="true" />
                        </div>
                        <div class="block">
                            <div class="div_LabelText">
                                <label>name:</label>
                            </div>
                            <cc1:TextInput ID="NameBox" runat="server" Text='<%# Bind("Name") %>' Required="true" />
                        </div>
                        <div class="block">
                            <div class="div_LabelText">
                                <label>from time:</label>
                            </div>
                            <telerik:RadTimePicker ID="RadTimePickerFromTime" runat="server" DbSelectedDate='<%# Bind("FromTime") %>' />
                        </div>
                        <div class="block">
                            <div class="div_LabelText">
                                <label>to time:</label>
                            </div>
                            <telerik:RadTimePicker ID="RadTimePickerToTime" runat="server" DbSelectedDate='<%# Bind("ToTime") %>' />
                        </div>
                        <div class="block">
                            <div class="div_LabelText">
                                <label>hoursPrMonth:</label>
                            </div>
                            <cc1:NumberInput ID="hoursPrMonthBox" runat="server" Text='<%# Bind("HoursPrMonth") %>'  />
                        </div>
                        <div class="block">
                            <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                
                  <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" FormNoValidate="true" />
                        </div>
                    </FormTemplate>
                    <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
</div>
Angel Petrov
Telerik team
 answered on 02 May 2013
2 answers
189 views
Hello,
I have a RadGrid that I am trying to place three controls inside a GridTemplateColumn/EditItemTemplate. Two buttons and a drop down list. When one of the buttons is fired I would like to see what value is selected in the DropDownList. I can't seem to access the control.

ASPX example:

<telerik:GridTemplateColumn>
                <EditItemTemplate>
                <p></p>
                    <asp:Button runat="server" ID="btnAddBox" CommandArgument="WHAT!" CommandName="AddBox" Text="Add Box To This Batch" />
                    <p></p>
                    <asp:DropDownList runat="server" ID="ddBoxList"></asp:DropDownList>
                    <asp:Button runat="server" ID="btnRemoveBox" CommandArgument="WHAT!" CommandName="RemoveBox" Text="Remove Box" />
                </EditItemTemplate>
            </telerik:GridTemplateColumn>


VB example:

Protected Sub rgBatchView_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles rgBatchView.ItemCommand
        If e.CommandName = "AddBox" Then
            Dim item = CType(e.Item, GridDataItem)
            Dim BatchID = item.GetDataKeyValue("BatchID")
            Dim b As New batch
            b.LoadBatch(BatchID)
            b.AddBox()
            notify.Show("Box Added!")
        ElseIf e.CommandName = "RemoveBox" Then
            Dim item = CType(e.Item, GridDataItem)
            Dim BatchID = item.GetDataKeyValue("BatchID")
            Dim b As New batch
            Dim dd As DropDownList = e.Item.Parent.FindControl("ddBoxList") ' **** This returns nothing, Also tried without ".parent"
            b.LoadBatch(BatchID)
            b.RemoveBox(dd.SelectedValue)
            notify.Show("Box Removed")
        End If
    End Sub

Thanks for any help!
David
Top achievements
Rank 1
 answered on 02 May 2013
1 answer
175 views
I have the same issue as in this thread: http://www.telerik.com/community/forums/aspnet-ajax/input/percentage-numerictextbox-possible-bind-display-format-difference.aspx

I followed the last example and created a new control and it works fine as long as there is data.

My issue is that I have values that are stored as 0. It is a sql float (vb.net Single) data type and will not store 0 as 0.0, so it returns 0. I can't bind to the dbValue in this case.

Is there a way to work around this issue?
Angel Petrov
Telerik team
 answered on 02 May 2013
2 answers
206 views
I have a radGrid that I create in the Page_Init. Below is my structure. In it you will see I have 4 items that make up my DataKeys. I also, at the bottom, create a GridTableView. That view has 5 items that make up my DayKey. The 4 same from above and 1 extra. I create 4 GridRelationFields. When I do this, my RadGrid1_DetailTableDataBind method gets called 4 times for each parent item. What am I doing wrong? I would have thought the RadGrid1_DetailTableDataBind would be called only once for each parent.

Page_Init
RadGrid1.ID = "RadGrid1"
RadGrid1.Width = Unit.Pixel(1500)
RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace
RadGrid1.AllowPaging = True
RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric
RadGrid1.AutoGenerateColumns = False
RadGrid1.ShowStatusBar = True
RadGrid1.AllowSorting = True
RadGrid1.AllowFilteringByColumn = True
RadGrid1.Skin = "WebBlue"
RadGrid1.ClientSettings.ClientEvents.OnGridCreated = "GetGridObject"
RadGrid1.ClientSettings.Scrolling.FrozenColumnsCount = 2
RadGrid1.ClientSettings.AllowColumnsReorder = True
RadGrid1.ClientSettings.ColumnsReorderMethod = GridClientSettings.GridColumnsReorderMethod.Swap
RadGrid1.ClientSettings.Selecting.AllowRowSelect = True
RadGrid1.ClientSettings.Resizing.AllowColumnResize = True
RadGrid1.ClientSettings.Scrolling.AllowScroll = True
RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = True
RadGrid1.ClientSettings.Scrolling.SaveScrollPosition = True
RadGrid1.MasterTableView.PageSize = 100
RadGrid1.MasterTableView.AllowMultiColumnSorting = True
RadGrid1.MasterTableView.DataKeyNames = New String() {"VendorListID", "Geography", "CirculationTypeID", "Day"}
columnCreation("Geography", "Geography", RadGrid1)
columnCreation("Circ Type", "CirculationTypeDescription", RadGrid1)
columnCreation("Household", "HouseHold_Count", RadGrid1)
columnCreation("Total Cov", "TotalCoverage", RadGrid1)
columnCreation("Day", "Day", RadGrid1)
columnCreation("Selected", "Selected", RadGrid1)
columnCreation("Circ", "Circ", RadGrid1)
columnCreation("Coverage", "Coverage", RadGrid1)
columnCreation("Zones", "Zones", RadGrid1)
RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
Dim tableSubCode As New GridTableView(RadGrid1)
tableSubCode.Name = "SubCodes"
tableSubCode.DataKeyNames = New String() {"VendorListID", "Geography", "CirculationTypeID", "Day", "Sub_Code"}
tableSubCode.Width = Unit.Percentage(100)
Dim relationFields1 As GridRelationFields = New GridRelationFields()
relationFields1.MasterKeyField = "VendorListID"
relationFields1.DetailKeyField = "VendorListID"
tableSubCode.ParentTableRelation.Add(relationFields1)
RadGrid1.MasterTableView.DetailTables.Add(tableSubCode)
Dim relationFields2 As GridRelationFields = New GridRelationFields()
relationFields2.MasterKeyField = "Geography"
relationFields2.DetailKeyField = "Geography"
tableSubCode.ParentTableRelation.Add(relationFields2)
RadGrid1.MasterTableView.DetailTables.Add(tableSubCode)
Dim relationFields3 As GridRelationFields = New GridRelationFields()
relationFields3.MasterKeyField = "CirculationTypeID"
relationFields3.DetailKeyField = "CirculationTypeID"
tableSubCode.ParentTableRelation.Add(relationFields3)
RadGrid1.MasterTableView.DetailTables.Add(tableSubCode)
Dim relationFields4 As GridRelationFields = New GridRelationFields()
relationFields4.MasterKeyField = "Day"
relationFields4.DetailKeyField = "Day"
tableSubCode.ParentTableRelation.Add(relationFields4)
RadGrid1.MasterTableView.DetailTables.Add(tableSubCode)
columnSubCodeCreation("SubCode", "Sub_Code", tableSubCode)
columnSubCodeCreation("Household", "HouseHold_Count", tableSubCode)
columnSubCodeCreation("Selected", "Selected", tableSubCode)
columnSubCodeCreation("Circ", "Circ", tableSubCode)
columnSubCodeCreation("Coverage", "Coverage", tableSubCode)
Me.PlaceHolder1.Controls.Add(RadGrid1)

RadGrid1_DetailTableDataBind

Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
Select Case e.DetailTableView.Name
    Case "SubCodes"
        Dim vendorListID As Integer = dataItem.GetDataKeyValue("VendorListID").ToString()
        Dim Geography As String = dataItem.GetDataKeyValue("Geography").ToString()
        Dim CirculationTypeID As Integer = dataItem.GetDataKeyValue("CirculationTypeID").ToString()
        Dim Day As String = dataItem.GetDataKeyValue("Day").ToString()
        If mintCircSetID > 0 Then
            e.DetailTableView.DataSource = GetDataTable(mstrSQL & ",1,'" & Geography & "'," & CirculationTypeID & ",'" & Day & "'")
        End If
End Select
David Kucharski
Top achievements
Rank 1
 answered on 02 May 2013
1 answer
159 views
How to do serverside clickevent on sitemap? is it possible? I'll be doing some serverside code onclick.
Thanks,
RJ 
Princy
Top achievements
Rank 2
 answered on 02 May 2013
0 answers
117 views
  1. is there a way to position the textboxes right below the handles of the slider displaying the handle's value? such that the textbox moves as the handle moves
Ashwijini
Top achievements
Rank 1
 asked on 02 May 2013
4 answers
910 views

Currently have a rad grid that will load fine in development but once it is moved into production receive a script timeout error.   In Production, the first load of the page works but have a RadComboBox that allows for Autopostback that changes the results in my RadGrid.  It is at this point that I receive the timeout.  Each time in production it will timeout after 30 seconds and have not figured out a way to stop it from timing out.  I have compared the values with IIS to compare script timeouts and they are the same.  It is trying to process 19,000 records, which I know it may take some time to query but in development the query doesn't take long at all to complete.

Following code is in web.config

<httpRuntime maxRequestLength="612353" executionTimeout="600"/>

Code found in ASPX page as I seen this suggested by others.

<telerik:RadScriptManager ID="RadScriptManager1" Runat="server"
    AsyncPostBackTimeout="600"></telerik:RadScriptManager>

Also added the following to my code and did not affect the outcome:

ValidateRequest="false"


In an attempt to resolve the problem I changed how my RadGrid would receive the data from client-side to code-behind where I could specify the command timeout and this has only caused the page to load for 5 seconds and not even return indications of and error.  Just not update my RadGrid, though it will change a information box that was created.

Looking for suggestions that might help in resolving this error. 

Kurt Kluth
Top achievements
Rank 1
 answered on 02 May 2013
6 answers
626 views
Hi, can I hide the expander on an ASP.NET radTreeView node?  I'm expanding the entire list upon load with checkboxes and don't want the users to expand/collapse since they are selecting search criteria. 

Thanks, Dave.
Plamen
Telerik team
 answered on 02 May 2013
3 answers
333 views
So I've created a grid that has a number of template columns that should remain entirely in "edit mode" (I set this in my C# code) so that I can edit my grid "live" (Excel like). Below is just a portion of my grid. When I'm trying to do the update, however, I don't know how to read the values from each cell in the grid. I've tried to do loops  such as Radgrid1.Items[i].Cells[j], and Radgrid1.Items[i].ExtractValues. I've also followed the batch update on this site but this doesn't work either. The question comes down to: How can I get data from each cell of the RadGrid. The cells can be anything from drop down menus to text boxes. Any help would be greatly appreciated

-Matt
    
        <telerik:RadGrid ID="RadGrid1" runat="server" Width="70%" AllowPaging="True"  
            Height="400px" AllowMultiRowEdit="True"   
             BorderColor="Black" BorderWidth="1px"  
            onselectedindexchanged="RadGrid1_SelIndexChange"  
            onprerender="RadGrid1_PreRender"  
            OnItemCommand="RadGrid1_ItemCommand" 
            onNeedDataSource="RadGrid1_NeedDataSource1" onitemdatabound="RadGrid1_ItemDataBound"  
             AllowAutomaticUpdates="True" 
            > 
            <AlternatingItemStyle BackColor="#E8E8E8" Font-Bold="False" Font-Italic="False"  
                Font-Overline="False" Font-Strikeout="False" Font-Underline="False"  
                Wrap="True" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> 
            <MasterTableView AutoGenerateColumns="False"  
                Width="100%" BorderColor="Black" BorderWidth="0px" GridLines="None"  
                EditMode="InPlace"  
                CommandItemDisplay="TopAndBottom" > 
                <Columns>  
                 
           <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" /> 
                          
                    <telerik:GridTemplateColumn UniqueName="DeleteColumn" HeaderStyle-Width="70px"
                        <EditItemTemplate> 
                            <asp:Button ID="DeleteButton" runat="server" Text="Delete" /> 
                        </EditItemTemplate> 
 
<HeaderStyle Width="70px"></HeaderStyle> 
                    </telerik:GridTemplateColumn> 
 
                    <telerik:GridTemplateColumn DataField="role" HeaderText="Role"  
                        SortExpression="role" UniqueName="role" HeaderStyle-Width="150px"
                        <EditItemTemplate> 
                            <asp:Label ID="roleLabel" runat="server" Text='<%# Eval("role") %>' Width="150px"></asp:Label> 
                        </EditItemTemplate> 
                        <HeaderTemplate> 
                            <asp:Label ID="rol_label" runat="server" Text="Role"></asp:Label> 
                        </HeaderTemplate>                 
 
</Columns> 
                  <CommandItemTemplate> 
                       <asp:Button runat="server" ID="UpdateAll" Text="Update All" CommandName="UpdateAll" /></CommandItemTemplate
                 
                 
            </MasterTableView> 
             
            <ClientSettings> 
                <Selecting AllowRowSelect="True" /> 
                <Scrolling ScrollHeight="100%" AllowScroll="True"  /> 
                <resizing allowcolumnresize="True"  /> 
            </ClientSettings> 
        </telerik:RadGrid>
Eyup
Telerik team
 answered on 02 May 2013
1 answer
108 views

I have a Radgrid with EnableHeaderContextMenu enabled to allow users to show/hide columns.

The checkbox and the label in column chooser window do not align.

Attached is the screenshot showing the behavior.

Eyup
Telerik team
 answered on 02 May 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?