Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
45 views
I want export ".doc" in event OnItemCommand of GridView but when i debug then it do not export.
Can you help me.
Code bihe:
if (e.CommandName == "ExportWord")
{
           string attachment = "attachment; filename=abc";
           HttpContext.Current.Response.Clear();
           HttpContext.Current.Response.AddHeader("content-disposition", attachment);
          // HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; //office 2003
           HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
          HttpContext.Current.Response.ContentType = "application/ms-word";
         HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
           HttpContext.Current.Response.Write("abc");
            HttpContext.Current.Response.End();
}
Vo
Top achievements
Rank 1
 answered on 25 Feb 2013
4 answers
167 views
Hi, I need some help please.  My menus don't have icon, so I don't want the right-area of where icon is displayed to show up.  see my attachment, the blue area is what I am talking about, I don't want to show up.  Please tell me how to do that.  thank you.

Ripon
Top achievements
Rank 1
 answered on 23 Feb 2013
1 answer
54 views
Hello,

I have a RadWindow. The window contains a table with two rows: the first row (sigle column) contains a RadTabStrip and the second (two colums) contains a checkbox and a button. Each TabStrip contains a RadTreeView:

<table style="width:100%;">
    <tr style="height:100%;vertical-align:top;overflow:auto">
        <td colspan="2">
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" SelectedIndex="0" Width="100%" Height="100%">
                <Tabs>
                    <telerik:RadTab runat="server" Text="Tab1" Selected="True">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Tab2">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" Width="100%" SelectedIndex="0" Height="100%">
                <telerik:RadPageView ID="RadPageView1" runat="server" Height="100%" style="border: 1px solid grey">
                    <telerik:RadTreeView ID="RadTreeView1" runat="server"></telerik:RadTreeView>
                </telerik:RadPageView>
                <telerik:RadPageView ID="RadPageView2" runat="server" Height="100%" style="border: 1px solid grey">
                    <telerik:RadTreeView ID="RadTreeView2" runat="server"></telerik:RadTreeView>
                </telerik:RadPageView>
            </telerik:RadMultiPage>
        </td>
    </tr>
    <tr>
        <td style="font: normal 12px arial; text-align: left;">
            <asp:CheckBox ID="CheckBox1" runat="server" Text="Do something when checked." AutoPostBack="true" />
        </td>
        <td style="text-align: right">
            <telerik:RadButton ID="CancelButton" runat="server" Text="Cancel" OnClientClicked="windowClose" UseSubmitBehavior="false">
            </telerik:RadButton>
        </td>
    </tr>
</table>

I want the content of the first row to autoresize if the RadWindow is resized and the second row to remain the same.

I've tried setting the row height to 100% but with no result.
Emil
Top achievements
Rank 2
 answered on 23 Feb 2013
4 answers
280 views
Hello,

I have the AllowCustomEntry set to true and I have the following scenario:
If the new Entry is an Email (has an email format) then add it normally, if the new Entry is not an email then
Check if the New Entry Exists in the DataSource/ENtryCollection, if it Exists then Do Nothing, if it doesn't exist
then I need to set the Background Color of the new Entry to Red.

This is what I have so far:


<script type="text/javascript">
    function OnClientEntryAdded(sender, eventArgs) {

        var newEntry = eventArgs.get_entry().get_text();
        if (validateEmail(newEntry)) {
             // If New Custom Entry is an Emeail Do Nothing
        }
        else {
// ELSE
// If New Custom Entry is Not an Email and It Does Not Exist in the 
// DataSource/Items then I want the New Added Entry to have a RED
// Background Color so that it indicates that the Entry is incorrect.
            
// IF newEntry does NOT exist in the EntryCollection THEN
// Change the Background COlor of the New ENtry to Red
        }
    }
 
 
    function validateEmail(email) {
 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
             
        return re.test(email);
    }
</script>


I also need to know how to use the remove() entry function within that event.




Eric
Top achievements
Rank 1
 answered on 22 Feb 2013
1 answer
312 views
I have the following custom sort handler in a radgrid.

For most columns, this is fine.  But on occasion my datafield name is different than my object field name.

ie.  a column with the following works
col.DataField = "Id";
col.UniqueName = "Id";
col.SortExpression = "Id";

but this column fails with error:

No property or field 'OnDate' exists in type 'EvidenceEntryGridItem


col.DataField = "DateEntered";
col.UniqueName = "DateEntered";
col.SortExpression = "OnDate";

This happens after the NeedDataSourceHandler finishes, so I am successfully getting results, and getting them into the grid.  It's something internal to the grid that is failing.

protected void OnSortCommand(object sender, GridSortCommandEventArgs e)
{
    SortDirection direction = (e.NewSortOrder == GridSortOrder.Descending)
                                  ? SortDirection.Descending
                                  : SortDirection.Ascending;
    Sort = new SortBy(e.SortExpression, direction);
     
    GridSortExpression newSortExpression = new GridSortExpression();
    newSortExpression.FieldName = e.SortExpression;
    newSortExpression.SortOrder = e.NewSortOrder;
 
    MasterTableView.SortExpressions.Clear();
    MasterTableView.SortExpressions.Add(newSortExpression);
 
    e.Canceled = true;
 
    this.PageInfo = new GridPageInfo(1, this.PageSize);
    this.Rebind();
}

NeedDataSource is pretty straight forward (it is in VB)

Protected Sub ResultsGrid_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles ResultsGrid.NeedDataSource
            Dim results As EvidenceEntryGridItemResultsEnvelope = AppDomain.Instance.DI.Get(Of IEvidenceEntryGridItemRepository)().GetForUserByUniqueId(_searchValue, UserId, ResultsGrid.PageInfo, ResultsGrid.Sort, ResultsGrid.Filter)
 
            ResultsGrid.VirtualItemCount = results.TotalCount
            ResultsGrid.DataSource = results.Records
 
        End Sub


Am I missing something in my sort handler?
Matthew
Top achievements
Rank 1
 answered on 22 Feb 2013
1 answer
101 views
Hi there,

My RadGrid filter function is not working with Simple data binding OnNeedDataSource, Any help is greatly appreciated. Here is my code (database is Northwind):

aspx file:
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
            GridLines="None" Width="800px" AllowFilteringByColumn="true" EnableLinqExpressions="false" AutoGenerateColumns="false"
             OnNeedDataSource="RadGrid1_NeedDataSource" OnPreRender="RadGrid1_PreRender" ShowFooter="True">
            <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
            ShowFooter="True" TableLayout="Auto">
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="Ship Name" SortExpression="ShipName" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    ShowFilterIcon="false">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbl_name" runat="server" Text='<%#Eval("ShipName")%>' Visible="true"/>
                        </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn HeaderText="Ship Country" SortExpression="ShipCountry" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    ShowFilterIcon="false">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbl_country" runat="server" Text='<%#Eval("ShipCountry")%>' Visible="true"/>
                        </ItemTemplate>
                   </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </form>
</body>

cs file
  
    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        LoadData();
    }
  
    private void LoadData()
    {
        RadGrid1.DataSource = GetDataTable("SELECT OrderID, OrderDate, Freight, ShipName, ShipCountry FROM Orders");
    }
  
    public DataTable GetDataTable(string query)
    {
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
  
        DataTable myDataTable = new DataTable();
  
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
  
        return myDataTable;
    }
  
  
  
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        //RadGrid1.Columns[0].CurrentFilterFunction = Telerik.Web.UI.GridKnownFunction.Contains;
        //RadGrid1.Columns[1].CurrentFilterFunction = Telerik.Web.UI.GridKnownFunction.Contains;
    }
Meng
Top achievements
Rank 1
 answered on 22 Feb 2013
1 answer
65 views
Hi,

I have a table implemented using radgrid and I have some linkbuttons (add, edit delete) on the top, all these buttons are functional,
however, I wonder if it is possible to make edit and delete not clickable or disabled or invisible if none of the row is selected?



Cheng
Jayesh Goyani
Top achievements
Rank 2
 answered on 22 Feb 2013
4 answers
199 views
I have a scenario where am processing files completely via Ajax with a custom handler.  As a file is uploaded and processed on the server, it is referenced in another area/control on the page where it can be deleted or otherwise affected.  As such, I want to remove it from the collection of files shown.

I attempted to do this in the fileUploaded event.  I traverse the files array returned from getUploadedFiles, compare the file names, and if it's the same, call deleteFileInputAt.  Unfortunately, this isn't working.  (I'm testing with multiple files of various sizes so that they finish in a random order).  It appears that the array of files returned from getUploadedFiles only includes the actual files that have been completed, so when I attempt to use the index from that array, it doesn't match the index I need to pass to deleteFileInputAt.

In the fileUploaded event handler, I would like a definitive reference to the file related file input, and then have a mechanism to remove that specific input.

Is this possible?

Here's some background in case there's another better way to do this...

I have a list of "things" on a page.  I have a window that I can open that allows me to add a new thing, and optionally upload file attachments for the thing.  I also open the window so the user can edit existing things and manage the attached files.  I would like the mechanism for deleting the files to be the same regardless if this is a new thing or an existing thing.  My plan was to have a list of uploaded files with a delete button for each.  The user could then just click the delete button to delete any attachments.  In order to be consistent with existing things and new things, I wanted to add a file reference to the list of attached files as soon as the file completes uploading, and at the same time, remove the file from the list of files shown in the AsyncUpload control.  Again, is this possible?

Thanks!
LeBear
Top achievements
Rank 1
 answered on 22 Feb 2013
0 answers
2.0K+ views

Q1 2013 (released Feb 20, 2013) brings a significant performance improvement to Telerik’s Grid for ASP.NET AJAX . Till Q1 2013, every hidden column (Visible=”false”) from the control used to store its cell data into the ViewState of the grid. However, in scenarios with many hidden columns or one hidden column bound to a large database this might have negatively impacted the performance of RadGrid.

We improved this behavior, so that the ViewState of RadGrid holds only the visible column data. However, if somewhere into the code you depend on the hidden column’s cell text which now will be empty (set to “&nbsp;”), this performance improvement will introduce a breaking change for you.

To resolve the issue for individual columns, you can replace the Visible property of the column with Display in order to get the corresponding value of the hidden column’s cell.

However, if the project is significantly large with many hidden columns or you want all of your invisible columns to hold their data, you can revert to the old behavior by setting the following property in the web.config file of the application:
<appSettings>
    <add key="BindGridInvisibleColumns" value="true"/>
</appSettings>

When the grid detects this setting, it will bind all invisible columns and put their values into the ViewState.

Please note that the BindGridInvisibleColumns property was introduced in 2014 Q2 SP1 (version 2014.2 724). With any previous versions, setting that property will not have any effect and you will still receive the previous behavior.
Telerik Admin
Top achievements
Rank 1
Iron
 asked on 22 Feb 2013
3 answers
53 views

Hello,

I am having a simple requirement, I have JavaScript function to detect if a control is 'changed' (I am using telerik and .net controls). Where as I am 'binding' the JavaScript function on runtime to all controls (attributes.add for .net controls and setting the properties for the telerik controls)

Now this function does work as expected ... until a post-back. As we know, we are going to loose our changes after post-back, So I just wanted to know if there is a way where ...

  • I can actually dump all those formatting attributes to some literal and can later iterate thru them and 're-apply' ?
  • Or is there a way to do partial post-back for just that control so that I do not loose my changes ?
  • Or any other way , you may think of ...

I am emphasising more on getting it done rather emphasising on getting in done correctly. I have had given a thought to add a custom attribute or so, but again I am afraid that I might loose them as soon as the page makes a trip for post-back.

I did spend few hours doing some research but most scenarios yield using hidden variables, I am not feeling it useful for my purpose explained above, but you can correct me.

Another problem was for asp:DropDownList ... I applied styles using JavaScript and nothing happened, I disabled the form decorator and styles were applies properly as expected

Danail Vasilev
Telerik team
 answered on 22 Feb 2013
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?