Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
697 views
I am very interested in using batch edit, but as most of the logic in our application is server-side, I need a way to server-side call a method on the RadGrid which is in Batch Edit mode upon post back of the page that asks it to save all edited items if any exist.

We have a save button which is OUTSIDE of the radgrid that saves not just the radgrid but also other data in the formview control - so when they click on that save button I want to invoke the save changes in the radgrid which is in batch edit mode.

Also in case they forget to click on the button but click on something else I want to auto-save without any user confirmation upon post back to the save (since I understand that all user changes are lost upon postback when you are in radgrid batch edit mode). How can I invoke "save batch mode if there are any changes" from a page_load method for example.

I see this http://www.telerik.com/support/code-library/prevent-losing-batch-editing-changes-on-paging-or-any-other-postback but I don't want a "are you sure" asked of the user - just an automatic invoking of saving any changed rows in the batch without asking the user any questions or requiring the user to click on any other buttons.

I cannot find this in the docs. It seems as if Telerik only allows invoking the save of radgrids in batch edit from client side javascript - not server side c#.
Marin
Telerik team
 answered on 26 Aug 2014
1 answer
455 views
Hi
I am facing an issue with this control. Any help is much appreciated.Below is my requirement
I have to allow maximum of 3 valid files to be uploaded so I set MaxFileInputsCount=3. Now I have some clientside validations and if the files are invalid I am removing them and I cannot see the files in UI but the upload control is not getting back to its original state. Lets say I upload a file and if it is valid I stream it to my DB. Now the count is 1 . I try again with another file and it is not a valid file then I show a message to the user and after the next upload the which is a valid file I am not seeing the upload control. EVen though I have just 2 files uploaded , the control is disappearing. Can anyone help me to resolve this issue. below is my script

function onClientFileUploading(sender, args) {
    debugger;
    var message = "";
    var errorWithFile = false;
    var regEx = /[~#%&*{}:<>?\/|\'\"]/;

    //Invalid Characters in File Name
    if (regEx.test(args.get_fileName())) {
        message = "File: " + args.get_fileName() + " contains invalid characters.  It has not been uploaded.  Please rename the file and upload again.";
        errorWithFile = true;
    }

    //Duplicate File Validation
    for (var fileindex in sender._uploadedFiles) {
        if (sender._uploadedFiles[fileindex].fileInfo.FileName == args.get_fileName()) {
            message = "You have already uploaded a file with the name " + args.get_fileName() + ". Please rename your new file and upload again.";
            errorWithFile = true;
            break;
        }
    }

    if (errorWithFile) {
        --filesSelected;
        args.set_cancel(true);
        sender._cancelUpload(args.get_row());
        sender._updateCancelButton(args.get_row());
        var index = $(args.get_row()).index();
        sender.deleteFileInputAt(index);
        sender.updateClientState();        
        alert(message);
    }
    MonitorFileUploadingQueue();
}

function onClientValidationFailed(sender, args) {
    var message = "";
    var errorWithFile = false;

    //File Extension Validation
    if (!sender.isExtensionValid(args.get_fileName())) {
        message = "File: " + args.get_fileName() + " selected has an invalid extension.";
        errorWithFile = true;
    }
    //MAX File Size
    else {
        message = "File: " + args.get_fileName() + " has exceeded the " + sender._maxFileSize / 1048576 + " MB file size limit.";
        errorWithFile = true;
    }

    if (errorWithFile) {
        debugger;
        --filesSelected;        
        var index = $(args.get_row()).index();
        sender.deleteFileInputAt(index);
        sender.updateClientState();
        
        alert(message);
    }

    MonitorFileUploadingQueue();
}

function MonitorFileUploadingQueue() {
    if (filesUploaded == filesSelected) {
        EnableDisableSubmitButton(true, "");
    }
    else {
        EnableDisableSubmitButton(false, "Uploading Files...");
    }
}

Thanks
Rakesh
Hristo Valyavicharski
Telerik team
 answered on 26 Aug 2014
1 answer
94 views
Hi Forum,

when I paste a text containing angle brackets, e. g. "test <test@domain.com>", into the auto complete box in token mode, both the text inside the brackets and the brackets themselves are not displayed:

"test <test@domain.com>" yields "test"

Anyhow, the brackets are still there, since I can access them via the "Text" property.

This behaviour can be reproduced with the Telerik demo on "http://demos.telerik.com/aspnet-ajax/autocompletebox/examples/default/defaultcs.aspx".

The texts inside the brackets should be displayed as well. How can I achive this?

Thanks for your help!

Roland
Nencho
Telerik team
 answered on 26 Aug 2014
9 answers
389 views
Hi,

I need to call javascript fxn on clicking "Save/Cancel/Close" button on Appointment EditForm. Currently, when I hit Save/Cancel button it  causes post back. How can I capture the client side event for these buttons? On clicking "X' on appointment edit form, it just closes the form, need to call javascript fxn on clicking close button.

Any idea?
Thanks
Prava
Bozhidar
Telerik team
 answered on 26 Aug 2014
1 answer
270 views
I have a radgrid in inline edit mode which has two raddatepicker in edit mode. when someone is typing some text that is not a date the datepicker will display an error sign inside the dateinput but when the person is clicking update button it updates the database by null. I want to cancel editing  when the error sign is in the inputdate box when the user click on update button. How can I do that?  my code is as below:
protected void ToolkitList_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem dataItem = (GridEditableItem)e.Item;
RadDatePicker pickerdue = (RadDatePicker)dataItem["ToolkitDueDate"].Controls[0];
pickerdue.ShowPopupOnFocus = true;
pickerdue.DatePopupButton.Visible = false;
pickerdue.Width = Unit.Pixel(80);


RadDatePicker pickerboard = (RadDatePicker)dataItem["BoardMeetingDate"].Controls[0];
pickerboard.ShowPopupOnFocus = true;
pickerboard.DatePopupButton.Visible = false;
pickerboard.Width = Unit.Pixel(80);


}

}

protected void ToolkitList_UpdateCommand(object sender, GridCommandEventArgs e)
{
try
{
if (e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editedItem = e.Item as GridEditableItem;


if (editedItem != null && editedItem.IsInEditMode)
{
                               
                        
                        int myUniqueId =
Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][" ID"]);
string labeloneText = string.Empty;
string labeltwoText = string.Empty;
RadDatePicker pickerdue = (RadDatePicker) editedItem["ToolkitDueDate"].Controls[0];
RadDatePicker pickerboard = (RadDatePicker) editedItem["BoardMeetingDate"].Controls[0];

if (!pickerdue.IsEmpty && !pickerboard.IsEmpty)
{

labeloneText = pickerdue.SelectedDate.ToString();
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
Convert.ToDateTime(labeloneText), Convert.ToDateTime(labeltwoText),
_currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}

// Update the toolkit's due date.
if (pickerdue.IsEmpty && pickerboard.IsEmpty)
{

labeloneText = pickerdue.SelectedDate.ToString();
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
null, null, _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}

if (pickerdue.IsEmpty && !pickerboard.IsEmpty)
{
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
null, Convert.ToDateTime(labeltwoText), _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}
if (!pickerdue.IsEmpty && pickerboard.IsEmpty)
{
labeloneText = pickerdue.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
Convert.ToDateTime(labeloneText), null, _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}
}
}

}
catch (Exception err)
{
                
 }
Princy
Top achievements
Rank 2
 answered on 26 Aug 2014
4 answers
459 views

For example

There is a radgrid whose width is 3000 px, and the resolution of my scree is 1920 * 1080.

Because of 1920 < 3000,  there is scroll bar in this radgrid.

This problem is that the grid's width is not set  (Means Auto? I guess...).

I tried to get value from RadGrid1Width but get nothing.

I also tried count all column width with loop like...

-----------------------------------------------------
double TotalSize = 0;

foreach (GridItem tmpIt in p_Grid.MasterTableView.Columns)
{
    TotalSize += tmpIt.Width.Value;
}
//TotalSize == 0.0
-----------------------------------------------------

How can I get 3000 px from the radgrid?

If I need to count all the column's width, what event I could use?

Thanks.
Princy
Top achievements
Rank 2
 answered on 26 Aug 2014
2 answers
154 views
I am using the sticky footer example and also a master page.  I have added a asp:panel inside a LayoutColumn which is in a LayoutRow and that of course is inside a RadPageLayout.

I can manually add the button and the panel to the ajax manager but the loading panel is never fired.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ButtonContact">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelContactForm" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Glow" MinDisplayTime="5000">
        </telerik:RadAjaxLoadingPanel>

If I try to use the ajax config wizard then neither the button or the panel are available to me. How can I reference them so they are ajax-ed? I have tried multiple combinations of the following as well.

protected void Page_Load(object sender, EventArgs e)
       {
           Panel PanelContactForm1 = (Panel)PageLayoutMaster.FindControl("PanelContactForm");
           Button ButtonContact1 = (Button)PanelContactForm1.FindControl("ButtonContact");
           RadAjaxManager1.AjaxSettings.AddAjaxSetting(ButtonContact1, PanelContactForm1);
       }

Thanks, Marty



moegal
Top achievements
Rank 1
 answered on 25 Aug 2014
1 answer
166 views
I have a RadTreeView on a form that is being populated by code with the node.add method described in your documentation. (http://www.telerik.com/help/aspnet-ajax/treeview-load-on-demand-client.html)  It works great for loading the items, but when you click one or do anything that causes a PostBack, all the items disappear.

APSX
<%@ Page Title="" Language="C#"  MasterPageFile="~/Content/themes/Level_One.Master" AutoEventWireup="true" CodeBehind="RequestManager.aspx.cs" Inherits="WebApplication.Forms.RequestManager" %>
 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ MasterType VirtualPath="~/Content/themes/Level_One.Master" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%: System.Web.Optimization.Styles.Render("~/Content/css") %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main_placeholder" runat="server">
    <telerik:RadCodeBlock ID="cb1" runat="server">
        <script type="text/javascript">
            function mngRequestStarted(ajaxManager, eventArgs) {
                // alert(eventArgs.get_eventTargetElement())
                var newArr = new Array();
                for (var name in ajaxManager) {
                    newArr.push(name + "<-->" + ajaxManager[name])
 
                }
            }
 
        </script>
    </telerik:RadCodeBlock>
 
    <telerik:RadScriptManager ID="main_radscriptmanager" runat="server" EnableViewState="true"></telerik:RadScriptManager>
    <telerik:RadAjaxLoadingPanel ID="main_loading" runat="server" Skin="Metro" EnableViewState="true"></telerik:RadAjaxLoadingPanel>
 
        <telerik:RadAjaxManager ID="main_ajaxmanager" runat="server" EnableAJAX="true" EnableViewState="true" ClientEvents-OnRequestStart="mngRequestStarted">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="tvRequestList">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="tvRequestList" LoadingPanelID="main_loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
 
                <telerik:AjaxSetting AjaxControlID="main_windowmanager">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="main_windowmanager" LoadingPanelID="main_loading" />
                        <telerik:AjaxUpdatedControl ControlID="wndw_permissions" LoadingPanelID="main_loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnSave" EventName="Click">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnSave" UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnCancel"></telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
 
    <asp:Button ID="cmdTest" runat="server" OnClick="cmdTest_Click" />
    <telerik:RadSplitter ID="RadSplitter1" runat="server" Height="700px" Width="100%" EnableViewState="false">
          <telerik:RadPane ID="Pane1" runat="server" Height="100%" Width="20%">
               <telerik:RadTreeView ID="tvRequestList" runat="server"
                   Skin="Metro" PersistLoadOnDemandNodes="true"
                   OnNodeExpand="tvRequestList_NodeExpand"
                   OnNodeClick="tvRequestList_NodeClick">
 
               </telerik:RadTreeView>
          </telerik:RadPane>
          <telerik:RadSplitBar ID="RadSplitbar1" runat="server" CollapseMode="Forward">
          </telerik:RadSplitBar>
          <telerik:RadPane ID="Pane2" runat="server">
               Pane2 - 100px
          </telerik:RadPane>
  <%--        <telerik:RadSplitBar ID="Radsplitbar2" runat="server" CollapseMode="Forward">
          </telerik:RadSplitBar>
          <telerik:RadPane ID="Pane3" runat="server" Height="150">
               Pane3 - 150px
          </telerik:RadPane>--%>
     </telerik:RadSplitter>
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1" EnableViewState="true"></telerik:RadWindowManager>
</asp:Content>

Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jabil.Core;
using DataEntities.Application.Context;
using DataEntities.Application.Entities;
using Telerik.Web.UI;
using System.Collections;
using System.Collections.Generic;
 
namespace WebApplication.Forms
{
    public partial class RequestManager : FrameworkPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.PageTitle = "Request Manager";
 
            if (!IsPostBack)
            {
                LoadRootNodes(tvRequestList);
            }
        }
 
        private void LoadRootNodes(RadTreeView tv)
        {
            using (RequestsDataContext rdc = new RequestsDataContext(string.Empty))
            {
                List<RequestManagerTreeList> tl = rdc.GetRequestManagerTreeViewList(1, 0, false).ToList<RequestManagerTreeList>();
                foreach (RequestManagerTreeList tlItem in tl)
                {
                    RadTreeNode tn = new RadTreeNode();
                    tn.Text = tlItem.ItemName;
                    tn.Value = ("L1" + tlItem.ItemId.ToString());
                    tn.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
                    tv.Nodes.Add(tn);
                }
            }
        }
 
        protected void tvRequestList_NodeExpand(object sender, RadTreeNodeEventArgs e)
        {
            try
            {
                using (RequestsDataContext rdc = new RequestsDataContext(string.Empty))
                {
                    string itemValue = e.Node.Value;
 
                    if (itemValue.Substring(0, 1) == "L")
                    {
                        int level = Convert.ToInt32(itemValue.Substring(1, 1)) + 1;
                        int itemId = Convert.ToInt32(itemValue.Substring(2, itemValue.Length - 2).ToString());
                        string levelTag = "L" + level.ToString();
                        List<RequestManagerTreeList> tl = rdc.GetRequestManagerTreeViewList(level, itemId, false).ToList<RequestManagerTreeList>();
                        foreach (RequestManagerTreeList tlItem in tl)
                        {
                            RadTreeNode tn = new RadTreeNode();
                            tn.Text = tlItem.ItemName;
                            tn.Value = levelTag + tlItem.ItemId.ToString();
                            if (level < 3)
                            {
                                tn.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
                            }
                            e.Node.Nodes.Add(tn);
 
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                show_error_message(ex.Message);
            }
        }
 
        protected void tvRequestList_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            show_error_message("Test");
        }
 
        private void show_error_message(string error_message)
        {
 
            string error = error_message.Replace("'", "");
 
 
            main_ajaxmanager.ResponseScripts.Add(string.Format("window.radalert(\"" + error + "\")"));
 
        }
 
        protected void cmdTest_Click(object sender, EventArgs e)
        {
            show_error_message("Test");
        }
    }
}

Scott
Top achievements
Rank 1
 answered on 25 Aug 2014
2 answers
86 views
Hi,

I'm calling a page containing a data pager. Part of my initial call url is a page number I would like to go to.
I searched around and tried a lot of things without success:
- FireCommand
- SEO Paging

What is the designed way to specify a start page for a data pager?

THANKS!
Jens-Thomas
Top achievements
Rank 1
 answered on 25 Aug 2014
2 answers
104 views
I have an application where I am dynamically creating a group of tabs, each one with a radgrid on it, from the code behind.  The radgrid includes a TemplateColumnEdit column (GridEditCommandColumn cannot be used because the link fires javascript to decide based on row data which of 7 types of dialog to present for editing).  Here is a portion of the code:

var colEdit = new GridTemplateColumn();
colEdit.UniqueName = "TemplateEditColumn";
colEdit.AllowFiltering = false;
colEdit.HeaderStyle.Width = Unit.Percentage(5);
colEdit.ItemStyle.VerticalAlign = VerticalAlign.Top;
colEdit.ItemTemplate = new TemplateColumnEdit("EditLink");

The column always says "Edit" regardless of the language/culture.  I need either to translate it, or to display ~/App_Themes/Default/RadGrid/Edit.gif.  How can this be accomplished from code behind?

Thank you.
Princy
Top achievements
Rank 2
 answered on 25 Aug 2014
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?