Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
91 views

I am using this code in my handler.ashx file

public void ProcessRequest(HttpContext context)
{
Context = context;
string filePath = context.Request.QueryString["path"];
filePath = context.Server.MapPath(filePath);
if (filePath == null)
{
return;
}
System.IO.StreamReader streamReader = new System.IO.StreamReader(filePath);
System.IO.BinaryReader br = new System.IO.BinaryReader(streamReader.BaseStream);
byte[] bytes = new byte[streamReader.BaseStream.Length];
br.Read(bytes, 0, (int)streamReader.BaseStream.Length);
if (bytes == null)
{
return;
}
streamReader.Close();
br.Close();
string extension = System.IO.Path.GetExtension(filePath);
string fileName = System.IO.Path.GetFileName(filePath);
if (extension == ".jpg")
{ // Handle *.jpg and
  WriteFile(bytes, fileName, "image/jpeg", context.Response);
}
else if (extension == ".gif")
{// Handle *.gif
WriteFile(bytes, fileName, "image/gif gif", context.Response);
}
else if (extension == ".pdf")
{// Handle *.pdf
WriteFile(bytes, fileName, "application/pdf pdf", context.Response);
}
}
/// <summary>
/// Sends a byte array to the client
/// </summary>
/// <param name="content">binary file content</param>
/// <param name="fileName">the filename to be sent to the client</param>
/// <param name="contentType">the file content type</param>
private void WriteFile(byte[] content, string fileName, string contentType, HttpResponse response)
{
response.Buffer = true;
response.Clear();
response.ContentType = contentType;
response.AddHeader("content-disposition", "attachment; filename=" + fileName);
response.BinaryWrite(content);
response.Flush();
response.End();
}
public bool IsReusable
{
get
{
return false;
}
}

It doesn't work for JPEG files. It just opens a blank page.

What am I doing wrong?

Vessy
Telerik team
 answered on 11 Oct 2018
1 answer
720 views

Dear team,

I have a radcombobox which fetches around 10000 items, below is the markup 

 

                              <telerik:RadComboBox ID="ddlProducts" runat="server"
                                AppendDataBoundItems="true" TabIndex="1"
                                Filter="Contains" Skin="MetroTouch" RenderMode="Auto" 
                                EnableLoadOnDemand="true" ShowMoreResultsBox="true" Width="100%" Height="400px" OnClientBlur="Product_OnClientBlur"
                                EnableVirtualScrolling="true" OnClientItemsRequesting="GetActiveProducts" OnClientDropDownClosed="onDropDownClosed">
                                <WebServiceSettings Method="GetActiveProducts" Path="~/Inventory/WebServices/InventoryWebService.asmx" />
                                
                            </telerik:RadComboBox>

Every this is working perfectly in desktop browser , the issue is with mobile device .

When we type in the keywords and the dropdownlist is populated with records and starts scrolling then in mobile device the page starts scrolling and when the page scroll reach the end then only the dropdownlist og combobox starts scrolling.

How to avoid this , Please advice

Please find the attached screenshot for this behaviour.

Thanks & Regards

Sushanth.B

 

 

Marin Bratanov
Telerik team
 answered on 11 Oct 2018
4 answers
301 views
We have a RadComboBox with CheckBoxes set true. The drop down stays open after checking a checkbox so you can check more, which is fine. The problem is that when you click in a textbox while the dropdown is open an entry cursor appears in the textbox briefly as it gets focus but clears as the textbox loses focus when the combobox dropdown closes. It is necessary to click the textbox a second time before typing into it. Alternatively the combobox arrow must first be clicked to close the dropdown before clicking the textbox to transfer the focus.

Is there some way to prevent the combobox from retaining the focus when another control is clicked?
Attila Antal
Telerik team
 answered on 10 Oct 2018
13 answers
487 views
Hi,

May i know possible to do set focus inside in-mode editng textbox in radgrid?

How to do that?

Please advice.

Thanks.
Soo
Attila Antal
Telerik team
 answered on 10 Oct 2018
1 answer
259 views
I am building a radgrid programmatically. Can anyone tell  me how to find out if a particular DataKeyName exists in the grid - something like e.Item.OwnerTableView.DataKeyNames.Contains("OBJECTID"). Since this is a generic grid, I might not know if a datakey exists. When I try to use GetDataKeyValue I get a null reference exception because a datakey might not exist.
Attila Antal
Telerik team
 answered on 10 Oct 2018
1 answer
412 views

I have a radgrid hierarchy structure.  When the user navigates to the third level and clicks on the parent tickmark on the grid, the RadGrid1_ItemCommand is fired and I can retrieve the parent "ProgramID". 

But I need to pickup the parentID when the user clicks on the command-template button located just on top of the detail rows.  I would like to get the value within a client-side function or server-side if that is easier??? (but cannot get that to work well).  See attachment for a jpg of grid...

 

Thank you for you help with this request!

 

Client-Side code:

function openConfirmationWindowNEW(sender, args) {

    var programID= parentItem.OwnerTableView.Items[sender.Item.ItemIndex].GetDataKeyValue("ProgramID");          

    radopen("Storyboard.aspx?carID=programID, "RadWindow2");

}

 

Server-Side Code:

console.write((string) sender.Item.OwnerTableView.Items[e.Item.ItemIndex].GetDataKeyValue("ProgramID").ToString());

 

The code works below but it needs it to work from within a client-side function....

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {

            if (e.Item.OwnerTableView.DataSourceID == "SqlDataSource3")
            {
                GridDataItem parentItem = (GridDataItem)(e.Item.OwnerTableView.ParentItem);
                if (parentItem != null)
                {
                    //..tier 2 parent
                    Console.Write(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["StrategicInitID"]);

                    //..tier 3 parent
                    HiddenProgramIDSelected.Value = (string)e.Item.OwnerTableView.Items[e.Item.ItemIndex].GetDataKeyValue("ProgramID").ToString();

                }
            }
    }

    

Attila Antal
Telerik team
 answered on 10 Oct 2018
1 answer
107 views
The radgrid has 3 parent tiers before getting to the details. Using a command template I like to create a new detail record by passing parentID. When clicking on add new record, I bring up a radwindow for the user to enter the data in the new record form. The radwind is shown using javascript. 


I would like to pass the parent ID from the third tier to the new record form. Unfortunately I can not find the parent id using javascript.


function openConfirmationWindowNEW(sender, args) {


// ... not working getting parentID "progranID"
var myprogramID = $find(Telerik.Web.UI.Grid.GetFirstParentByTagName(sender.get_element().parentNode, "ProgramID").id);

radopen("newrecord.aspx?carID= " + programID , "RadWindow2");
}




Attila Antal
Telerik team
 answered on 10 Oct 2018
5 answers
334 views

Hey guys,

 Is there a quick way to set the alternate row color based on a column value? For example: if I have 10 rows, and the first 3 belong to user ABC, next 5 belong to DEF and last 2 belong to GHI, Instead of having every row alternate, I'd like for the rows belonging to user ABC behave as NormalItem, then the rows belonging to DEF user as AlternatingItem and for GHI again as NormalItem.

This whole expected behaviour of Normal and AlternatingItem conflicts with the odd/even rules as per this doc but business rules win the case every time.

I can add some logic in the ItemDataBound event and set the CSS classes there, but am wondering if there is a better/efficient way to do it.

Chris
Top achievements
Rank 1
 answered on 10 Oct 2018
6 answers
130 views

Good afternoon, I believe we have a bug in the Rad Grid.

I have the following code to display a grid with a date field formatted a {0:d}. Being in Australia this begins correctly in d/MM/yyyy format, but as soon as you scroll (the scond click does it) the format changes to MM/dd/yyyy (american date format). Setting virtualization to false cures it. Setting the format explicitly cures it, but as we have an international application I don't want to do that. There are no OnScroll events on the page or server that I have added. Any ideas?

 

<telerik:RadGrid ID="dgSessions" runat="server"  AutoGenerateColumns="false"
            AllowSorting="true" GroupingEnabled="false" 
            EnableHeaderContextMenu="true" AllowPaging="true" PageSize="1000" OnNeedDataSource="dgSessions_NeedDataSource">
                
            <MasterTableView TableLayout="Auto">
                <Columns>
                     <telerik:GridDateTimeColumn UniqueName="SessionKey" HeaderText="" DataField="SessionKey" DataFormatString="<a target='_blank' href='SessionDetails.aspx?sessionkey={0}'>View</a>" ReadOnly="True" ShowSortIcon="False" ShowFilterIcon="False">
                    </telerik:GridDateTimeColumn>

 

                    <telerik:GridDateTimeColumn UniqueName="Date" HeaderText="Date" DataField="StartTime" DataFormatString="{0:d}" ReadOnly="True" >
                    </telerik:GridDateTimeColumn>

 

                    <telerik:GridBoundColumn UniqueName="StartTime" HeaderText="Start" DataField="StartTime" DataFormatString="{0:HH:mm}" ReadOnly="True" AllowFiltering="False" ShowSortIcon="False" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>
                   
                </Columns>
            </MasterTableView>
            <ClientSettings ReorderColumnsOnClient="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
                <Virtualization EnableVirtualization="True" InitiallyCachedItemsCount="20000"
                    LoadingPanelID="RadAjaxLoadingPanel1" ItemsPerView="20"/>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False" AllowResizeToFit="True"></Resizing>
                <ClientEvents OnGridCreated="GridCreated" />
            </ClientSettings>
            <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>

        </telerik:RadGrid>

Mary
Top achievements
Rank 1
 answered on 09 Oct 2018
1 answer
126 views

I use a RadAutoCompleteBox with DataScouceID set inside an InsertItemTemplate of a RadGrid. When clicking on add-record button i got a 'DataSource not set' exception. I have to use the OnDataSourceSelect function to manually control the amount of data. It seems that the databounding has to be earlier. I tried to set the DataSource in the ItemCreate event on the RadGrid, and do not use the DataScouceID property. But in this case, I got an ReadOnlyDataSource in the OnDataSourceSelect event passed and the solution provided below does not work any more. 

Could you please tell me what to do in order to keep the function txtSciMapUser_DataSourceSelect as it is?

Thanks a lot.

 

protected void txtSciMapUser_DataSourceSelect(object sender, AutoCompleteBoxDataSourceSelectEventArgs e)
{
    SqlDataSource source = (SqlDataSource)e.DataSource;
    RadAutoCompleteBox autoCompleteBox = (RadAutoCompleteBox)sender;
 
    string filterString = e.FilterString;
    string likeCondition = string.Format("'{0}{1}%'", autoCompleteBox.Filter == RadAutoCompleteFilter.Contains ? "%" : "", filterString);
 
    source.SelectCommand = "SELECT TOP 100 * FROM sm_user WHERE [" + autoCompleteBox.DataTextField + "] LIKE " + likeCondition;
}
Marin Bratanov
Telerik team
 answered on 09 Oct 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?