Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
341 views
Howdy all.

So, I have a RadMenu where the user clicks a button that opens a RadWindow.  Then the user can click anywhere else but on the window itself and close said window.  That works beautifully.

I now have a RadGrid with a GridTemplateColumn that has a LinkButton.  LinkButton goes to the code behind, figures stuff out, and if all is good, redirects to another page in the project.  If something is awry and it can't for some reason, it instead pops up a default RadAlert that says 'Something's wrong'.  The RadAlert is Modal and appears over the RadWindow, not letting the user have any interaction on the page under it.  THAT works.

Here's where I'm going cross-eyed: Once I hit Ok, I want the RadWindow with the grid to stay open, and the RadAlert to close.  However, my code for 'Click Anywhere and close' is tripping, and I'm not sure how to let it know that the click on the RadAlert is ok.

This is also, adding shades of complexity, part on a master page, and part on the content page.  I'll mark which bit is where.

Here's my code.

First, menu and window I want to stay up - this is on the Content page:
<telerik:RadMenu id="menuEmp" ClientIDMode="Static" runat="server" flow="Vertical" OnClientItemClicked="MenuOpenWindow" Width="100%"
    BackColor="#37495D">
    <Items>
      <telerik:RadMenuItem ImageUrl="../Images/button1.png" Value="EmpProj" />
    </Items>
</telerik:RadMenu>
 
<telerik:RadWindow id="winEmpProj" runat="server" Top="0" Left="0" Style="z-index: 8000" EnableEmbeddedSkins="false" OffsetElementID="divEmpHeader"
    ShowContentDuringLoad="false" VisibleStatusbar="false" VisibleTitlebar="false" AutoSize="true">
    <ContentTemplate>
        <div id="divProjListList" runat="server" style="width: 400px;">
            <div>Projects</div>
            <div style="width: 400px">
                <telerik:RadGrid ID="grdEmp" runat="server" AutoGenerateColumns="False"
                    Skin="" EnableLinqExpressions="False" CellSpacing="0" EnableViewState="False">
                    <ClientSettings Selecting-AllowRowSelect="false" EnablePostBackOnRowClick="true" />
                    <MasterTableView DataKeyNames="KeyColumn" ShowHeader="true" HeaderStyle-HorizontalAlign="Center" EnableViewState="false">
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="EmpNo" HeaderText="EmpNo" ItemStyle-HorizontalAlign="Left">
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnEmpNo" runat="server" OnClick="LoadEmp"><%# DataBinder.Eval(Container.DataItem, "EmpNo")%></asp:LinkButton>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Department" />
                            <telerik:GridBoundColumn DataField="Project" />
                            <telerik:GridBoundColumn DataField="Supervisor" />
                            </telerik:GridBoundColumn>
                        </Columns>
                        <HeaderStyle HorizontalAlign="Center" />
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                </telerik:RadGrid>
            </div>
        </div>
    </ContentTemplate>
</telerik:RadWindow>

Now, the Menu specific Javascript, also on the Content page.
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        function MenuOpenWindow(windowTitle) {
            var oWindow;
            var offsetElementBounds;
            var menu = $find("<%=menu.ClientID%>");
            var menuItem = menu.findItemByValue(windowTitle).get_element();
  
            //Closes the last window opened
            if (lastOpenedWindow) {
                lastOpenedWindow.close();
                lastOpenedWindow = null;
            }
             
            if (windowTitle == "EmpProj") {
                if (lastWindowTitle != "EmpProj") {
                    oWindow = $find("<%=winEmpProj.ClientID%>");
                    oWindow.show();
                    if (oWindow.get_offsetElementID()) {
                        offsetElementBounds = $telerik.getBounds($get(oWindow.get_offsetElementID()));
                        var x = offsetElementBounds.x + (menuItem.offsetWidth / 3);
                        var y = menuItem.offsetTop + offsetElementBounds.y - (menuItem.offsetHeight / 3);
                        oWindow.moveTo(x, y);
                    }
                    lastOpenedWindow = oWindow;
                    lastWindowTitle = "EmpProj";
                    return false;
                } else {
                    lastWindowTitle = null;
                }
            }
        }
    </script>
</telerik:RadScriptBlock>


Now, the VB code behind of the Content page.  First method is where the window is opened, and the second is where the RadAlert is generated.
Private Sub menuEmp_ItemClick(sender As Object, e As Telerik.Web.UI.RadMenuEventArgs) Handles menuEmp.ItemClick
    Select Case e.Item.Value
        Case "Endorsed"
            grdEndorsed.DataSource = Nothing
            grdEndorsed.Rebind()
    End Select
    Dim scriptstring As String = "function f(){{MenuOpenWindow('" & e.Item.Value & "');;Sys.Application.remove_load(f);}};Sys.Application.add_load(f);"
    ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "showWindow", scriptstring, True)
End Sub
 
Private Function LoadEmp()
    'Stuff done
    If {stuff true} Then
        'Do stuff
    Else
        Dim winManger As RadWindowManager = Master.FindControl("RadWindowManager1")
        winManger.RadAlert("Something's Wrong", 50, 100, "Project", "message")
        Exit Sub
    End If
End Function

Because this Javascript is used throughout the project on multiple pages, it's on the Master page.
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        //Global Variables
        var lastOpenedWindow;
        var lastWindowTitle;
        var alertWindowUp;
 
        function message(args) {
            //This is here to give RadWindow serverside a place to go.
            if (lastWindowTitle == "EmpProj" && args == true) {
                alertWindowUp = true;
            }
        }
 
        function pageLoad() {
            $addHandler(document, "click", onClickHandler);
        }
 
        function onClickHandler(e) {
            var targedNodeName = e.target;
 
            if (lastOpenedWindow) {
                // If the RadWindow is clicked then do nothing ;
                if ($telerik.isMouseOverElementEx(lastOpenedWindow.get_popupElement(), e)) return;
 
                lastOpenedWindow.close();
                lastOpenedWindow = null;
                lastWindowTitle = null;
 
                if (alertWindowUp == true) {
                    lastWindowTitle = null;
                    MenuOpenWindow("EmpProj");
                    alertWindowUp = false;
                }
            }
        }
    </script>
</telerik:RadScriptBlock>

And finally, the RadWindowManager on the Master.  Not much too it, but it is there!
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Style="z-index: 8000" />

Any ideas?  Thanks all!
Amanda
Top achievements
Rank 1
Iron
 answered on 28 Oct 2013
8 answers
384 views
Hi,

I am using RadMenu in one of my aspx pages. I have some javascript on the "OnClientItemClicked". which sets some JS varaibles . After a postback, I am loosing all values of the variables, which has to be set based on the currently selected radmenu. Is there way to trigger the "OnClientItemClicked" for the currently selected RadMenu?

Thanks,
Tony
Princy
Top achievements
Rank 2
 answered on 28 Oct 2013
25 answers
642 views
We've got a project in which there is heavy use of the radscheduler component, which is great.  Now, however, the client wishes to be able to print the schedule in a monthly view and weekly view.  I started looking at a reporting services plugin that had a calendar control but the bottom line is that I want it to look exactly like the radscheduler on the page.  I have thought of trying to make a bigger version that would fill a portrait or landscape page and just thell the user to print.  Obviously the background colors are going to be lost, etc... and good luck telling them to switch those settings.

What's really needed here is a way to export the RadScheduler to a printable format.  For example:

RadScheduler1.ExportAsPDF("portrait");

That is a simplified parameter but if there was a way we could basically get the control to "render itself" into a PDF or even an image then printing can be achieved.  What would be best about feeding out a PDF bytestream is that we could save the PDF and use those PDFS to provide nice snapshots of the calendar in various times.

The two areas would be month view and week view.... eventually you could do it for all of the other views.

How tough would this be to implement?  Is there a workaround to achieve this that I'm not thinking of?  I would rather not use any other thirt party calendar controls/products, Telerik has it looking perfect I just need to print it! :-)


Boyan Dimitrov
Telerik team
 answered on 28 Oct 2013
16 answers
413 views
Hello,
  I am adding below tag <ExportSettings in the <telerik:RadScheduler runat="server" ID="RadScheduler1" .........> Tag
<
ExportSettings OpenInNewWindow="true" FileName="SchedulerExport">
                <Pdf PageTitle="Schedule" Author="Telerik" Creator="Telerik" Title="Schedule" />
            </ExportSettings>

there is button to export pdf:

protected void btnExportPdf_Click(object sender, EventArgs e)
    {
        RadScheduler1.ExportToPdf();
    }
but the problem is no pdf open to download. It's resize the radScheduler control in small size when i click in Export button and no download popup page. I see in demo page path:http://demos.telerik.com/aspnet-ajax/scheduler/examples/pdfexport/defaultcs.aspx.

How is the problem I can't understand.

Please help me as soon as possible.


Thanks

Jiten Mutum
Boyan Dimitrov
Telerik team
 answered on 28 Oct 2013
1 answer
56 views
I want wen user click on Button "Choose Image" magemanager will appear. then when user click on an imager, image's url wil appear on a text box
ckeditor can do this but not good. I don't know how to do that with rad controls can you hel me
Thankss
Ianko
Telerik team
 answered on 28 Oct 2013
1 answer
80 views
I have the following issue with my grid needdatasource method, can't figure out why this keeps happening and its killing me:

    void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGrid grid = (RadGrid)sender;
        string id = grid.ID;
        DataTable current = (DataTable)HttpContext.Current.Session[int.Parse(id.Split(new string[] { "RadGrid" }, StringSplitOptions.RemoveEmptyEntries)[0])];
        grid.DataSource = current;
    }

If i go to the page directly no problems what so ever, everything works perfect,but if i try to navigate to that page from a different page, lets say using server.trasnfer or response.redirect, i keep getting this error:

Unable to cast object of type 'System.Int32' to type 'System.Data.DataTable'.

On this line, does anyone know why this would happen or how to fix it?
Eyup
Telerik team
 answered on 28 Oct 2013
1 answer
229 views

I am trying to use the client side repaint method. But I can not seem to get it to work.  Can anyone give me the correct way to access the method?


Part of my javascript function:

            var payeeElement = window.$find(var_radPayeeSearchClientID_fromASPX);
            payeeElement.control.repaint();



Thanks.
Shinu
Top achievements
Rank 2
 answered on 28 Oct 2013
1 answer
140 views
Hi,

I have the following script rendering in my aspx:


Sys.Application.add_load(function () {
    var target = $find('{0}');
 
    alert(target.get_id());
    //finds it
 
    $addHandler(target, "OnClientItemsRequested", function (sender, e) { alert('OnClientItemsRequested'); });
    $addHandler(target, "onclientItemsRequested", function (sender, e) { alert('onclientItemsRequested'); });
    $addHandler(target, "clientItemsRequested", function (sender, e) { alert('clientItemsRequested'); });
    $addHandler(target, "clientitemsrequested", function (sender, e) { alert('clientitemsrequested'); });
    $addHandler(target, "onclientitemsrequested", function (sender, e) { alert('onclientitemsrequested'); });
 
    //none fires
});

The alert showing server id fires, nothing else happens after using the auto-populate, while the same event works when I configure the event-handler in combobox's properties.

My problem is none of the subscriptions works, so is there a way to attach an event-handler function for OnClientItemsRequested in JS?

Thx in advance,
Branimir Giurov
Shinu
Top achievements
Rank 2
 answered on 28 Oct 2013
20 answers
1.3K+ views
After setting a filter, I need to get the count of the records that match the filter. 

The footer displays it but I can't figure out how it does it.

Thanks,

Chad
Princy
Top achievements
Rank 2
 answered on 28 Oct 2013
1 answer
709 views
I am having trouble with formatting a column that is bound to a nullable datetime field. The grid is bound on the client side using ajax. Wondering if anyone has seen this behavior before, and if so, what the solution was.

Here is the part of the grid instantiation code that formats the nullable datetime field:

columns.Bound(c => c.MediaFileVersion.MediaFile.LastCheckOutDate).ClientTemplate("<#= $.telerik.formatString('{0:MM/dd/yyyy - hh:mm tt}', GetDateFrom(LastCheckOutDate)) #>").Title("Check-out Date");
                        

The LastCheckOutDate field is of type nullable datetime.

The page has a javascript error like this:

Uncaught ReferenceError: LastCheckOutDate is not defined

It seems that Telerik grid does not know how to render a nullable datetime field. Would appreciate any help or ideas relating to the above problem.

Thank you




Viktor Tachev
Telerik team
 answered on 28 Oct 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?