Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
319 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
332 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
119 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
69 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
219 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
81 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
5 answers
213 views
Is there a Rad control to use that acts like a ComboBox but outputs a 
<select>
<option></option>
</select>

instead of the <ul> <li> it creates?  On mobile devices we want the list to pop up the device's default select option viewer. But since the Rad ComboBox generates a ul li this is not possible.  
Wouldn't it have been a better option to develop the ComboBox as a <select> instead of a <ul>?  I am not quite sure of the reasoning behind that.
But either way, is there a rad control that outputs a <select> drop down list instead of the <ul>.

Thanks in advance.

EDIT:

So a revision to my question. We found that there is a property for the ComboBox to set RenderingMode="Simple", HOWEVER, it does not seem to be switching out our RadComboBox to <select> elements, it is keeping the default. I checked the HTML output in Firebug and nothing has changed.  The RadComboBox is inside a RadGrid that is triggered when "Add new record" selected.
 Any reasons why setting the RenderingMode to Simple doesn't work???
Hristo Valyavicharski
Telerik team
 answered on 22 Feb 2013
16 answers
681 views
I'm using RadGrid with object datasource. I'm using telerik:GridTemplateColumn to display Gender (GenderCode = 1 --> GenderCodeText = male, GenderCode = 2 --> GenderCodeText = female):
<telerik:GridTemplateColumn DataField="GenderCode" DataType="System.Byte" SortExpression="GenderCodeText"
    HeaderText="Gender" UniqueName="Gender">
    <ItemTemplate>
        <asp:Label ID="LblGender" runat="server" Text='<%# Eval("GenderCodeText") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadComboBox ID="CboGender" runat="server" SelectedValue='<%# Eval( "GenderCode") %>'
            DataSourceID="OdsGenders" DataTextField="Description" DataValueField="Code">
        </telerik:RadComboBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

If I export grid values to CSV, all values for Gender are exported as empty string. If I use ExportToExcel (or ExportToWord) instead of ExportToCSV, everything works OK.

Could you help me please?

     Richard
Kostadin
Telerik team
 answered on 22 Feb 2013
3 answers
611 views
I have a ASP.Net app with a user control that contains the RadTreeView control. Currently the RadTreeView control does not have any double click event define. However, double clicking a node in the tree does collapse or expand it's child nodes. I assume this is the default behavior for the RadTreeView. This is the desired behavior we want.

I want to add an OnNodeClick event to this tree so a user can select a node and fire an event.

However, some pages that consume this user control don't want the OnNodeClick event. Instead they want to be able to just select/highlight a node. These are the same pages that want the Double click to expand and collapse the nodes.

When I add the OnNodeClick event to the RadTreeView user control, the pages that want the OnNodeClick event work as desired.

But the original pages that don't want the OnNodeClick event work OK except that the Double Click no longer collapses or expands the nodes. When double clicked, the node collapses then expands immediately.

How can I turn the OnNodeClick event off on some pages and on for other pages?

Or, can I programmatically  define the OnNodeClick event dynamically on the pages that needs it?


Plamen
Telerik team
 answered on 22 Feb 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?