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

Hi,

 

I have a multipage control that has 5 tabs. On the 2nd tab Ihave a grid which displays order details and on the 5th tab I have another grid which allows the selection of a product to be inserted into the grid on tab #2. When the product row is double-clicked a RadWindow is popped into which the full order details can be added. On completing the data entry a button then inserts the added data into the datatable which is the source of the grid on tab #2 and executes a "CloseAndRebind" script in the window code-behind e.g.:

protected void btnInsertClicked(object sender, EventArgs e)
{
    DataSet ds = Session["OrdersTables"] as DataSet;
    DataRow nr = ds.Tables["LineItems"].NewRow();
 
    nr["LineItem_Id"] = GetNewItemId(23);
    ...
    .... data inserted into DataRow
    ...
    ds.Tables["LineItems"].Rows.Add(nr);
 
    // update the session
    Session.Remove("OrdersTables");
    Session.Add("OrdersTables", ds);
 
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
}

 

This script comes from one of your examples :

function CloseAndRebind(args) {
    GetRadWindow().BrowserWindow.refreshGrid(args);
    GetRadWindow().close();
}

 

which bubbles back to the parent page and triggers this AJAX request to execute a ReBind on the grid in tab #2

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" DefaultLoadingPanelID="mainLoadingPanel">
    <AjaxSettings
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <UpdatedControls
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="grid2LoadingPanel" /> 
                    </UpdatedControls
                </telerik:AjaxSetting
            </AjaxSettings>   
</telerik:RadAjaxManager>

 

The AJAX request triggers the NeedDataSource event of the grid on tab #2 to re-load the DataSource however on switching to tab #2 the grid was still showing the old data. At this point clicking the refresh option top-right of the grid the NeedDataSource event is again triggered and this time the new line is displayed.

I'd like the AJAX request to switch to tab #2 and then issue the refresh so coded:

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    if (e.Argument == "Rebind")
    {
        // swap back to the order lines tab then refresh it
        RadTab rt = RadTabStrip1.Tabs.FindTabByText("Order Items");
        rt.Selected = true;
 
        RadGrid1.MasterTableView.SortExpressions.Clear();
        RadGrid1.MasterTableView.GroupByExpressions.Clear();
        RadGrid1.Rebind();
    }
}

 

However the swap back to tab #2 fails to happen and the grid is still not refreshed.

CP
Top achievements
Rank 1
Iron
 answered on 20 Oct 2016
14 answers
262 views

Hi

I'm working with Gantt control but I'm stuck on 2 things. I need to handle events like:

- Change progress of a task

- Delete key pressed on (in order to cancel deleting process)

I'd be grateful for your help because I spent a few hours already on that and didn't find the solution.

 

Thanks,

Maciek

Ivan Danchev
Telerik team
 answered on 20 Oct 2016
2 answers
118 views

My RadScheduler, on page load, appears squished up (see the squished.jpg). When I click the "today" button in the RadScheduler, it expands and appears normal size (see NormalSize.jpg).

Why does it do this, and how can I just make it appear normal size on page load?

Thanks

Veselin Tsvetanov
Telerik team
 answered on 20 Oct 2016
2 answers
413 views

Hi Telerik,

 

1. Is there a way to validate a GridBoundColumn so that it does the following:

  • if it is empty, display a "This field is required!" message
  • allow only numbers and up to 3 digits only

2. Is there a way to validate another GridBoundColumn so that it does the following:

  • if it is empty, display a "This field is required!" message
  • allow only one-character letters, specifically ("A","B","C"), if input is not any of these 3, to display an error message.

3. How do I convert No. 2 above to a GridDropdownColumn and also satisfy the same validation requirements? Dropdown option should display:

  • Please pick a fruit
  • A=Apple
  • B=Banana
  • C=Corn

Thanks as always.

Konstantin Dikov
Telerik team
 answered on 20 Oct 2016
1 answer
1.1K+ views

Hello, I have a radGrid on my page that reads a SQL statement and returns the data in the grid upon first load. I have a button where users could import a tab delimited CSV file and display it to the grid. I believe that the process would go as: 1) Import CSV & store in dataTable 2)Clear radGrid original Data 3)set datasource of Radgrid to the newly made Datatable. Is this a efficient way of going about this? If so How would I clear the radGrid & set the radgrid to a new datasource?

 

aspx.vb(UploadButton)

 Protected Sub Upload(sender As Object, e As EventArgs)
        'Upload and save the file
        Dim csvPath As String = Server.MapPath("~/File") + Path.GetFileName(FileUpload1.PostedFile.FileName)
        FileUpload1.SaveAs(csvPath)

        Dim dt As New DataTable()
        dt.Columns.AddRange(New DataColumn(3) {New DataColumn("Category ID", GetType(String)), New DataColumn("Category Label", GetType(String)), New DataColumn("Attribute Label", GetType(String)), New DataColumn("Attribute Type Label", GetType(String))})

        Dim csvData As String = File.ReadAllText(csvPath)
        For Each row As String In csvData.Split(Environment.NewLine) 'How to split csv?'
            If Not String.IsNullOrEmpty(row) Then
                dt.Rows.Add()
                Dim i As Integer = 0
                For Each cell As String In row.Split(","c)
                    dt.Rows(dt.Rows.Count - 1)(i) = cell
                    i += 1
                Next
                'ReceiptGrid.DataSource = Nothing
                ''ReceiptGrid.Rebind(dt.DataSet);

               

            End If

        Next

        Me.ReceiptGrid.DataSource = Nothing
        Me.ReceiptGrid.DataBind()
        'Dim consString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        'Using con As New SqlConnection(consString)
        '    Using sqlBulkCopy As New SqlBulkCopy(con)
        '        'Set the database table name
        '        sqlBulkCopy.DestinationTableName = "" 'What database to write it to?
        '        con.Open()
        '        sqlBulkCopy.WriteToServer(dt)
        '        con.Close()
        '    End Using
        'End  
    End Sub

 

aspx(RadGrid)

 

   <telerik:RadGrid ID="ReceiptGrid" runat="server" AllowFilteringByColumn="True" AllowMultiRowEdit="True" AllowPaging="True" DataSourceID="Attributes" Height="787px" Skin="Glow" Width="1000px" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" style="margin-left: 0px; margin-top: 4px;" HorizontalAlign="Justify" CellPadding="0" PageSize="18" RenderMode="Native">
        <GroupingSettings CollapseAllTooltip="Collapse all groups">
        </GroupingSettings>
        <ExportSettings ExportOnlyData="True">
            <Excel Format="Xlsx" />
            <Csv EncloseDataWithQuotes="False" ColumnDelimiter="Tab" RowDelimiter="Comma" />
        </ExportSettings>
        <ClientSettings>
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" DataSourceID="Attributes" CommandItemDisplay="Top" PageSize="15">
           
          
            <RowIndicatorColumn Visible="False">
                <HeaderStyle Width="41px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn Created="True">
                <HeaderStyle Width="41px" />
            </ExpandCollapseColumn>
           
          
            <CommandItemSettings ShowExportToExcelButton="True" ShowExportToCsvButton="True" />
           
          
            <Columns>
                <telerik:GridBoundColumn DataField="CategoryID" FilterControlAltText="Filter CategoryID column" HeaderText="Category ID" SortExpression="CategoryID" UniqueName="CategoryID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CategoryLabel" FilterControlAltText="Filter CategoryLabel column" HeaderText="Category Label" SortExpression="CategoryLabel" UniqueName="CategoryLabel">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AttributeLabel" FilterControlAltText="Filter AttributeLabel column" HeaderText="Attribute Label" SortExpression="AttributeLabel" UniqueName="AttributeLabel">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AttributeTypeLabel" FilterControlAltText="Filter AttributeTypeLabel column" HeaderText="Attribute Type Label" SortExpression="AttributeTypeLabel" UniqueName="AttributeTypeLabel">
                </telerik:GridBoundColumn>
                <telerik:GridEditCommandColumn>
                </telerik:GridEditCommandColumn>
                <telerik:GridClientDeleteColumn FilterControlAltText="Filter column column" UniqueName="column">
                </telerik:GridClientDeleteColumn>
            </Columns>

<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
</EditFormSettings>
        </MasterTableView>

<FilterMenu RenderMode="Native"></FilterMenu>

<HeaderContextMenu RenderMode="Native"></HeaderContextMenu>
    </telerik:RadGrid>

 

 

 

 

Konstantin Dikov
Telerik team
 answered on 20 Oct 2016
2 answers
180 views

Hello all!

 

I have a RadGrid with BatchEdit mode. 

I need take the client side value of some cells when users update the grid.

But when i check the values of the cells in onUpdate or onItemUpdate event of RadGrid I can only acces to old values. How i can get the client side values of the edited cells?

 

Thanks you for your time!!!

Marc
Top achievements
Rank 1
 answered on 20 Oct 2016
3 answers
296 views
Hi,  in my radwizard,  I have multile steps with different groups.  I try to find a way to bypass the validation when I press "previous" button.  There is no way I can hit previous without my required field validator interrupting me.

I found a thread where you ask to add the following javascript :
function OnClientButtonClicking(sender, args) {
                if (sender.get_activeIndex() > args.get_nextActiveStep().get_index()) {
                     args.set_cancel(true);
                     sender.set_activeIndex(args.get_nextActiveStep().get_index());
                 }
            }
When I debug,  I can see the script is called but there is something else preventing the page from going to the previous one.  Required field validator kicks in as soon as I hit previous.
Thank you for your help
Veselin Tsvetanov
Telerik team
 answered on 20 Oct 2016
5 answers
828 views
(1) In a multi-column RadCombo, is there some way to get a value from the selected row (which is not the SelectedValue and not the SelectedText)? Client-side preferred.

(2) In a multi-column RadCombo, is there some way to get the input area to display in columns matching the dropdown?
Peter Milchev
Telerik team
 answered on 20 Oct 2016
7 answers
152 views

Hi,

We are using a workaround, once provided by you, to decorate checkboxes in treeview.

This was working fine until the new 2016 Q3 release...

In IE11, the hack doesn't work anymore, all other browsers are working!

The problem is that after a postback, all checked nodes are unchecked in IE11!

Is there an other workaround available, or can I do anything to make this work in IE11 again?

The workaround that work in previous versions looked like this:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="treeview.aspx.vb" Inherits="TestaTredjepartWeb.treeview" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="s" runat="server">
        </asp:ScriptManager>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function pageLoad()
                {
                    var $ = $telerik.$;
                    var tree = $('#<%= RadTreeView1.ClientID %>');
                    var decorator = $find('<%= RadFormDecorator1.ClientID %>');
 
                    var boxes = $('input[type*=checkbox]');
 
                    boxes.removeAttr('class');
 
 
                    decorator.decorate(document.documentElement);
                    boxes.addClass('rtChk');
 
 
                }
 
                //Workaround 1 - attach to the OnClientNodeChecking event and manually set the decorator classes:
 
                function OnClientNodeChecking(sender, args)
                {
                    var decoratedCheckBox = $telerik.$(args.get_node().get_element()).find('input.rfdRealInput').next()[0];
                    if (decoratedCheckBox.className.indexOf("Unchecked") != -1)
                    {
                        decoratedCheckBox.className = "rfdCheckboxChecked";
                    } else
                    {
                        decoratedCheckBox.className = "rfdCheckboxUnchecked";
                    }
                }
 
 
                //Workaround 2 - remove the preventDefault() method of the TreeView when the checkbox is decorated ($target[0].id.indexOf("RadFormDecorator") == -1):
 
 
                //Telerik.Web.UI.RadTreeView.prototype._preventLabelDefault = function (nodeElement, e) {
                //    $ = $telerik.$;
                //    var target = $telerik.getTouchTarget(e),
                //        $target = $(target),
                //        targetIsLabelDescendant = $(nodeElement).find("label").eq(0).has(e.target).length !== 0;
 
                //    //We should not prevent the default when the target is a link or the checkbox itself.
                //    //Also when the target is not a direct descendant of the label, which is the case when templates are used.
                //    if (targetIsLabelDescendant && $target[0].id.indexOf("RadFormDecorator") == -1 && !$target.is("a") && !$target.is("input")) {
                //        e.preventDefault();
                //    }
                //};
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Default" />
        <div>
            <telerik:RadTreeView ID="RadTreeView1" runat="server" RenderMode="Lightweight" CheckBoxes="true" OnClientNodeChecking="OnClientNodeChecking">
                <Nodes>
                    <telerik:RadTreeNode Text="aaa">
                        <Nodes>
                            <telerik:RadTreeNode Text="123" />
                            <telerik:RadTreeNode Text="234" />
                            <telerik:RadTreeNode Text="345" />
                            <telerik:RadTreeNode Text="456" />
                            <telerik:RadTreeNode Text="567" />
                        </Nodes>
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeView>
            <asp:Button ID="Button1" runat="server" Text="Click to do postback" />
        </div>
    </form>
</body>
</html>

 

Regards
Andreas

Danail Vasilev
Telerik team
 answered on 20 Oct 2016
3 answers
124 views

I had a grid which I would like to sort. However, it appears (and acts like) sorting is not enabled.

1st Quarter 2016

Here is my grid definition. There is quite a bit going on in the code behind, as this grid is datasource driven. I have code in prerender, itemcreated, columncreated and needdatasource, but nothing I can determine would affect the sort capabilities.

 

<telerik:RadGrid
ID="grdReportRecords"
runat="server"
RenderMode="Lightweight"
width="99%"
AllowSorting="True"
AllowMultiRowSelection="True"
AllowFilteringByColumn="true"
OnNeedDataSource="grdReportRecords_NeedDataSource"
ActiveItemStyle-BackColor="Yellow"
GroupPanelPosition="Top"
Skin="Silk">
<GroupingSettings
CollapseAllTooltip="Collapse all groups"
CaseSensitive="false">
</GroupingSettings>
<ClientSettings>
<Selecting
AllowRowSelect="true" />
<%--<Resizing AllowResizeToFit="true"
AllowColumnResize="true"
ResizeGridOnColumnResize="true"/>--%>
<ClientEvents
OnColumnCreated="ColumnCreated">
</ClientEvents>
</ClientSettings>
<ExportSettings
ExportOnlyData="True"
HideStructureColumns="True">
<Excel Format="Xlsx" />
</ExportSettings>
<MasterTableView
AllowMultiColumnSorting="true"
DataKeyNames="ReqID"
AllowSorting="true"
AllowFilteringByColumn="true"
CommandItemDisplay="top">
<CommandItemSettings
ShowAddNewRecordButton="false"
ShowExportToExcelButton="true"
ShowRefreshButton="False" />
<Columns>
<telerik:GridHyperLinkColumn
DataNavigateUrlFields="ReqID, RequestTypeAbbrev"
DataNavigateUrlFormatString="javascript:ShowEditForm({0}, '{1}')"
ImageUrl="images/view.gif"
UniqueName="GridLink_Edit"
HeaderText="View"
AllowFiltering="False">
<HeaderStyle HorizontalAlign="Center" width="40"/>
<ItemStyle HorizontalAlign="Center" width="40"/>
</telerik:GridHyperLinkColumn>
<telerik:GridClientSelectColumn
UniqueName="ClientSelectColumn">
<HeaderStyle HorizontalAlign="Center" width="40"/>
<ItemStyle HorizontalAlign="Center" width="40"/>
</telerik:GridClientSelectColumn>
<%--<telerik:GridTemplateColumn UniqueName="Select">
<HeaderTemplate>
<asp:CheckBox ID="chkView1" runat="server" onclick="selectall_clicked(this)" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkView" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>--%>
<%--<telerik:GridTemplateColumn
UniqueName="View"
AllowFiltering="false">
<HeaderTemplate>
<asp:CheckBox
ID="chkView1"
runat="server"
onclick="return selectall_clicked(this);" />
<telerik:RadCheckBox ID="chkView1" runat="server" />
</HeaderTemplate>
<FilterTemplate>

</FilterTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkView" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>--%>
</Columns>
</MasterTableView>
<ClientSettings>
<ClientEvents OnColumnCreated="ColumnCreated" />
</ClientSettings>
<ActiveItemStyle BackColor="Yellow">
</ActiveItemStyle>
</telerik:RadGrid>

 

Could you please help?

 

 

Kostadin
Telerik team
 answered on 20 Oct 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?