Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
304 views

I want to call a function that writes a file for download from a RadContextMenu.  The function works fine when I call it from a button click. But I can't call it from the server side OnContextMenuItemClick because the Response.End() call doesn't let the menu click finish (the load icon just keeps going).  So I am trying to intercept the menu click on the client side, cancel the event, and post the button click instead.  My breakpoint on javascript _doPostBack() gets hit,  my breakpoint on Page_Load gets hit, but my breakpoint on ButtonRptRpt_Click function does not.  Why not?

How can I download a file as a result of a RadMenuItem click? (Opening another browser tab is not an option.)

<telerik:RadTreeView ID="TreeViewBatchRules" runat="server" CheckBoxes="True"
    MultipleSelect="True" ToolTip="Right-click on nodes to see rule batch run menu."
    OnClientContextMenuItemClicking="TreeViewBatchRules_ClientContextMenuItemClicking"
    OnContextMenuItemClick="TreeViewBatchRules_ContextMenuItemClick">
    <DataBindings>
      <telerik:RadTreeNodeBinding Expanded="False" />
    </DataBindings>
    <ContextMenus>
      <telerik:RadTreeViewContextMenu ID="TreeViewBatchRulesContextMenu" runat="server">
        <Items>
          <telerik:RadMenuItem Value="Thing1" Text="Thing 1">    
             </telerik:RadMenuItem>
             <telerik:RadMenuItem Value="CreateReport" Text="Create Report">
             </telerik:RadMenuItem>
        </Items>
      </telerik:RadTreeViewContextMenu>
    </ContextMenus>
  </telerik:RadTreeView>
   
<!-- works fine on button click --> 
<asp:Button ID="ButtonRunRpt" runat="server" Text="Run Report" OnClick="ButtonRunRpt_Click" />

function TreeViewBatchRules_ClientContextMenuItemClicking(sender, eventArgs) { 
    var node = eventArgs.get_node();
    var item = eventArgs.get_menuItem();
    var menu = item.get_menu();   
 
    if (item.get_text() == "Create Report"){
        eventArgs.set_cancel(true);
        var ruleId = node.get_value();
 
        // the postback gets called but doesn't "arrive" at the ButtonRunRpt_Click
        var btnId = "<%=ButtonRunRpt.ClientID %>"
        __doPostBack(btnId, '');
    }           
}
protected void TreeViewBatchRules_ContextMenuItemClick
                  (object Sender,
                       Telerik.Web.UI.RadTreeViewContextMenuEventArgs e)
{
    int ruleId = int.Parse(TreeViewBatchRules.CheckedNodes[0].Value);
 
    switch (e.MenuItem.Value)
    {
       case "Thing1" : ... break;
       case "CreateReport" : BuildReport(ruleId); break; // load icon won't go away; file doesn't download       
    }
}
 
 
protected void ButtonRunRpt_Click(object Sender,
                                  EventArgs e)
{
    int ruleId = int.Parse(TreeViewBatchRules.CheckedNodes[0].Value);
    BuildReport(nodeId); 
}  
 
private void BuildReport(int nodeId)
{
    var ms = GetReport(ruleId);
     
    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Buffer = true;
    HttpContext.Current.Response.ContentType = "application/pdf";  
    HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename='myReport.pdf'");     
 
    Response.BinaryWrite(ms);
     
    HttpContext.Current.Response.Close();
    HttpContext.Current.Response.End();
}
Nencho
Telerik team
 answered on 15 Jul 2016
5 answers
834 views

Why does my RadGrid trigger page postback upon filtering from client-side?
I populate the data from code-behind and I use JS to trigger the filter by calling a function.
The problem is present even if I use filtering through the RadGrid's filtering controls to test.

Here is my code:

HTML:

<telerik:RadGrid ID="AssetGrid" runat="server" CssClass="asset-grid"
                        Width="100%" Height="100%"
                        OnNeedDataSource="AssetGrid_NeedDataSource">
                        <PagerStyle Position="Bottom" PageSizeControlType="RadComboBox" Mode="NextPrevAndNumeric" />
                        <FilterMenu EnableImageSprites="False" />
                        <ClientSettings AllowColumnHide="True" EnableAlternatingItems="false"
                            EnableRowHoverStyle="true">
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            <Selecting AllowRowSelect="true" />
                        </ClientSettings>
                        <MasterTableView AllowPaging="true" PageSize="20" AllowFilteringByColumn="true" AutoGenerateColumns="false" DataKeyNames="id, name" TableLayout="Fixed" ClientDataKeyNames="id, name">
                            <Columns>
                                <telerik:GridBoundColumn DataField="id" DataType="System.Int32" SortExpression="id" UniqueName="id" Visible="false" />
                                <telerik:GridBoundColumn DataField="name" DataType="System.Int32" SortExpression="title" UniqueName="title" AutoPostBackOnFilter="false" Visible="false" />
                                <telerik:GridBoundColumn DataField="categoriesid" DataType="System.String" SortExpression="categoriesid" UniqueName="categoriesid" Visible="false" />
                                <telerik:GridBoundColumn DataField="primarycategoryid" DataType="System.String" SortExpression="primarycategoryid" UniqueName="primarycategoryid" AutoPostBackOnFilter="false" Visible="true" Display="false" />
                                <telerik:GridTemplateColumn UniqueName="description">
                                    <ItemStyle
                                        VerticalAlign="Top" HorizontalAlign="Left"
                                        CssClass="data-item" />
                                    <ItemTemplate>
                                        <table class="font-roboto data-item-table" style="table-layout: fixed; width: 100%; pointer-events: none;">
                                            <tr>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                                <td colspan="1" style="width: 8.33333333333%;"></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style='<%# "background-color:" + c.ParseColorIntToRGB(Eval("color").ToString()) + ";" %>'>
                                                    <%# Eval("statusabbrev").ToString().ToUpper() %>
                                                </td>
                                                <td colspan="10">
                                                    <%# Eval("name") %>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" rowspan="4">
                                                    <%--<video preload="metadata" style="min-height: inherit; width: 100%; height: 100%; max-width: 100%; max-height: 100%;" onclick="if (!this.paused) { this.pause(); } else { this.play(); };" ondblclick="this.pause(); $(this).fadeOut(500, function() { this.load(); $(this).fadeIn(); });">
                                                        <source src='<%# Eval("filepath") %>' type="video/mp4">
                                                    </video>--%>
                                                </td>
                                                <td colspan="2">
                                                    Category
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("primarycategory") %>
                                                </td>
                                                <td colspan="2">
                                                    ID
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("itemcode") %>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    Genre
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("ea_genre") %>
                                                </td>
                                                <td colspan="2">
                                                    Duration
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("title_duration") %>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    Creator
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("creator") %>
                                                </td>
                                                <td colspan="2">
                                                    Updated By
                                                </td>
                                                <td colspan="3">
                                                    <%# Eval("title_last_updated_by") %>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    Created
                                                </td>
                                                <td colspan="3">
                                                    <%# String.Format("MMMM d, yyyy h:mm:ss tt", Eval("created")) %>
                                                </td>
                                                <td colspan="2">
                                                    Updated
                                                </td>
                                                <td colspan="3">
                                                    <%# String.Format("MMMM d, yyyy h:mm:ss tt", Eval("title_last_update")) %>
                                                </td>
                                            </tr>
                                        </table>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>

 

JavaScript:

function filterGrid(value, gridClientID, columnname, operator, args) {
    if (operator == undefined || operator == '' || operator == null) {
        operator = 'EqualTo'
    }
    if (columnname == undefined || columnname == '' || columnname == null) {
        return;
    }
 
    function AddFilterExpression(grid, dataField, filterFunctionName, filterValue) {
        var master = grid.get_masterTableView();
        master.filter(dataField, filterValue, filterFunctionName);
    }
    var grid;
    if (gridClientID == null || gridClientID == undefined || gridClientID == '') {
        grid = $find('<%=AssetGrid.ClientID %>');
    }
    else {
        grid = $find(gridClientID);
    }
 
    var noValue = false;
    if (value == null || value == undefined || value == '') {
        noValue = true;
    }
    if (noValue) {
        if (args == null || args == undefined || args == '') {
            return;
        }
    }
 
    if (grid != null) {
        if (noValue) {
            value = args.get_node().get_value();
            args.set_cancel(false);
        }
        AddFilterExpression(grid, columnname, operator, value);
    }
    else {
        if (noValue) {
            args.set_cancel(true);
        }
    }
}
Viktor Tachev
Telerik team
 answered on 15 Jul 2016
4 answers
2.2K+ views

Hi,

When I selected rows and that I refresh my page with F5, the rows are not selected but the checkboxes are still checked.

On Page_Load, I tried to do :
- Radgrid.SelectedIndexes.Clear()
- Radgrid.Rebind()
- Radgrid.Datasource = null

But It doesn't work.

Viktor Tachev
Telerik team
 answered on 15 Jul 2016
9 answers
336 views

I have a ImageGallery for showing all thumbnails in a page with Width="100%", which shows fine, but I can't figure out two things:

1. How do you get Height=100%?  I want the gallery to fill the browser page.

2. On resize of the browser window, how do I get the control to resize and adjust the layout to match?

This is what I have for the control right now:

<telerik:RadImageGallery runat="server" ID="rigItems" DisplayAreaMode="Thumbnails" Width="100%" Visible="true" LoopItems="false" AllowPaging="false" ImagesFolderPath="~/"
    DataImageField="ImageUrl" DataTitleField="ImageTitle" DataThumbnailField="ImageUrl" OnNeedDataSource="rigItems_NeedDataSource" >
    <ImageAreaSettings Height="600px" ResizeMode="Fit" />
    <ThumbnailsAreaSettings Height="800px" ShowScrollButtons="false" ThumbnailsSpacing="1px" ThumbnailHeight="200" ThumbnailWidth="200" Mode="Thumbnails" ScrollOrientation="Vertical" ShowScrollbar="true" />
</telerik:RadImageGallery>

Viktor Tachev
Telerik team
 answered on 15 Jul 2016
1 answer
175 views

Our control are using sunset skin and we want to change to Yellow color but still going to use the sunset skin. 

I have check the forum but unable to get the sunset skin css so that I can customize it. 

Kindly advise how i can still use the skin and only change the color background to yellow color. 

 

Thanks in advance 
Andrew

Peter Milchev
Telerik team
 answered on 15 Jul 2016
7 answers
249 views

Hello,

     My Grid is in GridEditMode.Batch.  I have two template columns.

      First Template Column uses a RadNumericTextBox
      Second Template Column uses a RadDatePicker.

 

Could you explain how to update the RadDatePicker's date when the RadNumericTextBox value changes USING the RadNumericTextBox's OnValueChanged CLIENT event please.

Viktor Tachev
Telerik team
 answered on 15 Jul 2016
5 answers
4.5K+ views
Hi,

I am using Raddatepicker and i want to select only Date part from the that textbox.
 i using like this DatePicker.SelectedDate

Like:  currently comming : 9/29/2011 12:00:00 AM

         required : 9/29/2011 or 09/29/2011.

and i want to pass in my method '09/29/2011' but Passing going '9/29/2011 12:00:00 AM


Thanks
Manish
Manish
Top achievements
Rank 1
 answered on 15 Jul 2016
1 answer
171 views

In body of Rad editor if i pasted the code below in HTML container -

<a href="http://members.farmtoconsumer.org/donations/" target="_blank">
<figure class="center-img">
<img style="border: 0px solid currentColor; border-image: none; width: 100%; max-width: 303px !important;" alt="Donate Today!" src="https://media.mercola.com/assets/images/donate-today.jpg">
<figcaption class="op-large op-center hide-figcap">
<a href="http://members.farmtoconsumer.org/donations/" target="_blank">Click Here</a>
</figcaption>
</figure>
</a>

After this when i switch from HTML to design and then again back to HTML the code changes to below code -

<a href="http://members.farmtoconsumer.org/donations/" target="_blank">
</a><figure class="center-img"><a href="http://members.farmtoconsumer.org/donations/" target="_blank">
<img style="border: 0px solid currentColor; border-image: none; width: 100%; max-width: 303px !important;" alt="Donate Today!" src="https://media.mercola.com/assets/images/donate-today.jpg">
</a><figcaption class="op-large op-center hide-figcap"><a href="http://members.farmtoconsumer.org/donations/" target="_blank">
</a><a href="http://members.farmtoconsumer.org/donations/" target="_blank">Click Here</a>
</figcaption>
</figure>

Notice that the <a> tag was immediately closed. It seems like the editor updates the codes accordingly (some sort of auto-correcting html codes I guess). Is there any way we can avoid this or is this something that we cannot modify or any solution for this?

Misho
Telerik team
 answered on 15 Jul 2016
1 answer
154 views

What is the best way to remove the style tag from tables (table, tr, td tags)?

I've been working with the OnClientPasteHtml event but I don't know how to reference the pasted content or the most effective way to accomplish this. Anyone have any ideas?

Nikolay
Telerik team
 answered on 15 Jul 2016
1 answer
89 views

Is it possible to export the Scheduler as a PDF document in memory?  I dont want the PDF to open in the current window or in another window. I wish to load the PDF in memory so i can either save it to a database or manipulate the PDF to merge it with another PDF.

Thanks

Plamen
Telerik team
 answered on 15 Jul 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?