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

I have a scenario similar to this thread:

http://www.telerik.com/community/forums/thread/b311D-bckhem.aspx

I have implemented a grid editing scenario with RadWindow and ajaxmanager using client-side script callbacks.

I have a master page and a content page.  Currently the Rad Ajax Manager resides in the content page.  I am not currently using
the Rad Ajax Manager Proxy.

Everything is working well so far and I am able to edit and add grid items and refresh the grid using client-side script and the rad Ajax manager.

The code so far looks like the following (code is from the content page - ClientDetail.aspx that displays the grid and a page that is opened in the rad window - ServiceEventDetail.aspx which does not use a master page)

ClientDetail.aspx: (abbreviated for clarity)  There is alot of AJAX stuff going on on the page as ther ar multiple grids on different tabs of a tabstrip. Sorry I can't get the code formatter to work for me so I just made everything blue.

<telerik:RadCodeBlock runat="server">
<script type="text/javascript">
 

function openEditEventWindow(ServiceEventID) {
    var oWnd = radopen("ServiceEventDetail.aspx?ServiceEventID=" + ServiceEventID, "Edit Service Event");
    oWnd.set_modal(true);
    oWnd.setSize(750, 600);
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move);
    oWnd.set_visibleStatusbar(false);
    oWnd.Center();
}
function openAddEventWindow() {
    //open a new window for adding a client comment parsing the URL request for the current client ID
    var oWnd = radopen("ServiceEventDetail.aspx?ClientID=" + gup('ClientID'), "Add Service Event");
    oWnd.set_modal(true);
    oWnd.setSize(750, 600);
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Reload);
    oWnd.set_visibleStatusbar(false);
    oWnd.Center();
}

function refreshServiceEventGrid() {
    var radMgr = $find("<%=RadAjaxManager1.ClientID %>");
    radMgr.ajaxRequest("Rebind_ServiceEvents");
}

</script>
</telerik:RadCodeBlock>

<telerik:RadGrid runat="server"
ID="radGridServiceEvents"
AllowMultiRowSelection="false"
ClientSettings-Selecting-AllowRowSelect="false">
<MasterTableView
    AutoGenerateColumns="False"
    DataKeyNames="ID"
    Width="100%"
    CommandItemDisplay="Top"
    PageSize="10"
    EnableNoRecordsTemplate="true">
...
    <Columns>
        <telerik:GridTemplateColumn
            UniqueName="TemplateEditColumn"
            HeaderText="View/Edit"
            HeaderStyle-Width="100">
            <ItemTemplate>
                <asp:ImageButton ID="EditButton" OnClientClick='<%# Eval("ID", "openEditEventWindow({0}); return false;" ) %>'  runat="server"  ImageUrl="./images/edit.gif"></asp:ImageButton>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
    <CommandItemTemplate>
        <table border="0" style="width:100%;">
            <tr>
                <td align="left"><td align="left"><input type="button"  value=" " onclick="javascript:openAddEventWindow()" id="AddNewEventButton" title="Add New Service Event" class="rgAdd" /><a  href="javascript:openAddEventWindow()">Add" originalAttribute="href" originalPath="javascript:openAddEventWindow()">Add" New Service Event</a></td></td>
            </tr>
        </table>
    </CommandItemTemplate>
   </MasterTableView>
 </telerik:RadGrid>

...

 <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
   <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="radGridServiceEvents" />
                <telerik:AjaxUpdatedControl ControlID="radGridComments" />
                <telerik:AjaxUpdatedControl ControlID="radGridClientDocuments" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ddlPrimaryRace">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ddlSecondaryRace" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="radGridServiceEvents">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="radGridServiceEvents" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="radGridClientDocuments">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="radGridClientDocuments" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="radGridComments">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="radGridComments" />
                <telerik:AjaxUpdatedControl ControlID="lblMessage" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

ClientDetail.aspx.cs

...

public void LoadServiceEvents(bool resetPage)
    {
        List<CSTServer.ServiceEvent> _ServiceEvents;
        if (_client == null)
        {
            _ServiceEvents = CSTServer.ServiceEventService.GetForClient(Int32.Parse(Request.QueryString["ClientID"]));
        }
        else
        {
            _ServiceEvents = _client.getServiceEvents(true);
        }

        if (_ServiceEvents != null)
        {
            radGridServiceEvents.DataSource = _ServiceEvents;

            if (resetPage == true)
            {
                radGridServiceEvents.CurrentPageIndex = 0;
            }
            radGridServiceEvents.DataBind();
        }
        radGridServiceEvents.Focus();
    }

...

    protected void  RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        switch (e.Argument)
        {
            case "Rebind_ServiceEvents":
                LoadServiceEvents(true);
                break;
        }
    }

...

ServiceEventDetail.aspx:

<script type="text/javascript">  
        //Get a reference to the the containing RadWindow  
        function GetRadWindow()  
        {  
            var oWindow = null;  
            if (window.radWindow) oWindow = window.radWindow;  
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
            return oWindow;  
        }          
        function CloseAndRebind(args)
        {
            GetRadWindow().Close();
            GetRadWindow().BrowserWindow.refreshServiceEventGrid(args);
        }
        function CancelEdit()
        {
            GetRadWindow().Close();  
        }
        </script>

and in the code behind

ServiceEventDetail.aspx.cs

private int SaveServiceEvent()
    {
        if (Request.QueryString["ServiceEventID"] != null)
        {
            //load the Client we're in edit mode
            _serviceEvent = ServiceEventService.GetByID(Int32.Parse(Request.QueryString["ServiceEventID"]));
           
            SaveScreenToServiceEvent();

            ServiceEventService.Save(_serviceEvent);
            //call the client side CloseAndRebind on reload of page after postbacl whhihc calls the parent refresh grid
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
        else if (!(Request.QueryString["ClientID"] == null))
        {
            //new ServiceEvent
            _serviceEvent = new ServiceEvent();
            _serviceEvent.ClientID = Int32.Parse(Request.QueryString["ClientID"]);
           
            SaveScreenToServiceEvent();
            ServiceEventService.Save(_serviceEvent);
           
            //call the client side CloseAndRebind on reload of page after postback which calls the parent refresh grid
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", true);
        }
        return _serviceEvent.ID;

    }

OK so far so good.  The problem is now I would like to start using the Rad Ajax Manager Proxy in the ClientDetail.aspx (Content Page)
and put the Rad Ajax Manager in the master page as I would like to update a control which is in the master page to return messages
to the user when the grid is updated via AJAX on the content page.  I am wondering given the complexity of this scenario, whether this is even worth it :-)

In the documentation for the Rad Ajax Manager Proxy:

"The purpose of the new control is to ease the design-time configuration only. The Proxy does not provide client-side functionality as the Manager does. There is no client-side object as well as functions like ajaxRequest/ajaxRequestWithTarget and client-side events. Instead, one can get the Manager instance through the GetCurrent static method similar to the ASP:ScriptManager control and call the master manager client-side methods if necessary. "

and

"Accessing master manager client-side from content page"

   <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
       <script type="text/javascript">
           function myUserControlClickHandler()
           {
               $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
           }
       </script>
   </telerik:RadCodeBlock>

 

So it would be possible to get the manager from the javascript code on the client on the content page, however this brings up the crux of the prolem:

1.  Will the RadAjaxManager1_AjaxRequest event be fired on the master page and have to be handled on the master page code behind?
That would mean that all Ajax requests initiated through client-side script throughout the application - I'm using this pattern all over the place - would have to be handled in a single function on the master page would you then have all the grid data-loading functions replicated in the master page.?..  Can you use delegate functions here?  do you have an example?

2.  If indeed the RadAjaxManager1_AjaxRequest resides in the code behind of the master page, how will it be able to access controls that are on the content page, and be able to compile.  Would all content page controls that are referenced from within RadAjaxManager1_AjaxRequest on the master page need to be addressed with FindControl and casting?

3.  Obviously maintaining the rad Ajax Manager configuration in the markup of the master page would become unmanageable for a large application.  Should I then programmatically configure the master page Ajax Manager from the content page code behind a rather than in the markup?  Could you convert my AJAX Manager Configuration to code as an example?

Sorry this is a long one, this stuff gets pretty complex and I wanted to be specific.

Thanks!

Jonathan
Iana Tsolova
Telerik team
 answered on 03 Oct 2008
1 answer
94 views

 Hi, greetings from Mexico

 I have a problem grouping Grid fields (a Grid with 32 columns)
When I do, the horizontal scrollbar is hidden, and the fields width is reduced,
and the Grid keeps its width (assigned on the designer)

Does anyone have any suggestion?
Thanks
Dimo
Telerik team
 answered on 03 Oct 2008
3 answers
479 views
Hi there,

I am new to RadControls, and I have the problem as follows:

I put a Rad Combobox in the detailview. This combobox is bound with Sqldatasource so that the users can choose a item from this dropdownlist to insert/update into the database. Everything works fine.

But I also want to set to allow Custom text, and when users want something which is not in the list, they can type in the box whatever they want to create new items. But I cannot find how to bind this new typed items with the database. Nothing happens when I type new texts into the box.

Please help.

Thanks.
Rosi
Telerik team
 answered on 03 Oct 2008
3 answers
101 views
Greetings,

Ok, so I'm doing an insert into my grid via itemcommand, and here is the code.

case "PerformInsert":  
                    rgdStatusList.Columns.FindByUniqueName("Active").Visible = true;  
                    rgdStatusList.Columns.FindByUniqueName("Archived").Visible = false;  
                    AddStatus(e);  
                    break;  
 
protected void AddStatus(Telerik.Web.UI.GridCommandEventArgs e)  
        {  
            Telerik.Web.UI.GridEditableItem insertItem = e.Item.OwnerTableView.GetInsertItem();  
            //e.Item as Telerik.Web.UI.GridEditableItem;  
            Status mStatus = new Status();  
            AdminManager mAdminManager = new AdminManager();  
 
            //Pull in all needed info to create a new record in the database.  
            mStatus.StatusDescription = (insertItem["StatusDescription"].Controls[0] as TextBox).Text;  
            mStatus.Active = (insertItem["Archived"].Controls[0] as CheckBox).Checked;  
            mStatus.CommunityID = ParentKNPage.CoPID;  
 
            try  
            {  
                mAdminManager.InsertStatus(mStatus);  
            }  
            catch (Exception ex)  
            {  
                rgdStatusList.Controls.Add(new LiteralControl("Unable to insert Status.  Reason: " + ex.Message));  
            }  
        } 

In there, my mAdminManager.InsertStatus(mStatus) does add the data into my database, and once the page refreshes, the grid rebinds and displays the data.  The problem is, once the page does it's postback, the insert textbox is still visible.  Is there a way to kick the grid out of insert mode?

Thanks.
Chad Johnson
Top achievements
Rank 1
 answered on 03 Oct 2008
2 answers
133 views
Hi,

when I call pasteHtml of a RadEditor instance the text gets inserted as expected but when I click inside the editor I get this error:
"Could not complete the operation due to error 800a025e".

What does this mean? Did I do something wrong? Here's the code which performs
the pasteHtml:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        <script type="text/javascript"
            function insertPlaceholder() { 
                var placeholerSelector = $find("<%= PlacholderSelectBox.ClientID %>"); 
                var editor = $find("<%= TemplateEditor.ClientID %>"); 
 
                editor.pasteHtml(placeholderSelector.get_value()); 
            } 
        </script> 
    </telerik:RadCodeBlock> 

Best Regards,
Robert
George
Telerik team
 answered on 03 Oct 2008
8 answers
334 views

I have a RadGrid with an associated RadContextMenu. When I right-click a row on the grid and click one of the context menu items I need to get at the selected row in the context menu's event handlers. However, I found that the SelectedItems collection is empty.

I was able to work around this by adding an OnRowContextMenu handler, with code like this:

function Grid_OnRowContextMenu(sender, args)
{
    var index = args.get_itemIndexHierarchical();
    var row = sender.MasterTableView.get_dataItems()[index];
    row.set_selected();
}

This partially works, but it seems like there should be an easier way to do this. For one, it doesn't deselect other selected rows. Right now I have to add this client-side handler to every single one of my grids. It seems like there should be some sort of property on the grid that enables row selection on right click.

One other problem I have is that I do not want the context menu to show when the grid has no rows. With the old RadGrid I was able to check the row's ItemType property. If it was "NoRecordsItem", I would not show the context menu.

Rosen
Telerik team
 answered on 03 Oct 2008
1 answer
307 views
Hi,

I am using Rad combo box , i want to know how I can reduce the spacing between items in dropdownlist. Any help appreciated.
Regards,
Jincy
Yana
Telerik team
 answered on 03 Oct 2008
3 answers
266 views
URL:
http://www.alchemedia.com.my/inpageedit.aspx


1. I have an editor in this page with display:none by default.
2. When user click on the content, the editor will be displayed.
3. When user click on outside, the editor should be hidden by using blur event.

However, the blur event is not working if the editor textarea is not focused.

I tried to use the code below but not working:

var editor = GetRadEditor("<%=RadContent.ClientID%>");  
editor.SetFocus();  


Am I missing something? Thanks



Rumen
Telerik team
 answered on 03 Oct 2008
1 answer
254 views
Hi,
 I am using tabstrip with vista skin and it is 2 level tabstrip. I want to make the selected tab's text to be bold.  And I want to make the whole second level tabs to be grey and and other tabs white with grey border.Like the menu in http://www.abb.com/ProductGuide/Alphabetical.aspx. Any help appreciated.

Regards,
Jincy
Yana
Telerik team
 answered on 03 Oct 2008
3 answers
236 views
Hi,

I have set

HTML
{
      overflow-x:hidden;
      overflow-y:hidden
}

to delete the scrollbars for RadWindow.
Now the problem is that RadEditor inside a RadWindow do not have a scrollbar in the editor area.

What´s the correct way to get both working?

Thanks and enjoy,
Chris
Martin
Telerik team
 answered on 03 Oct 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?