Telerik Forums
UI for ASP.NET MVC Forum
2 answers
760 views
I have a bunch of buttons that each bring up the same context menu.  I need the context menu to position itself at the mouse click on the button.

In ASP.NET this is accomplished by using code like this.

function OpenAddRowMenu(event) {
    var contextMenu =  $("#AddRowMenu");
    if ((!event.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), event.relatedTarget))) {
        contextMenu.show(event);
    }
    else {
        alert("Event error");
    }
}

The button

<button class="btn btn-primary" onclick="OpenAddRowMenu(event); return false;">Add Row</button>
 
I cannot find anything on positioning a context menu or any possible parameters to show().  The MVC documentation is really thin and the examples only show so much.
George
Top achievements
Rank 2
 answered on 05 Feb 2015
1 answer
404 views
Hi there

We are using Kendo Charts in our application. We can successfully export the charts using the following jQuery.
$("#exportASPBarChart").click(function () {
    var chart = $("#ASPBarChart").data("kendoChart");
    var image = chart.imageDataURL();
    var a = $("<a>").attr("href", image).attr("download", "ASPBarChart.png").appendTo("body");
    a[0].click();
});
Is there a way to export the data to a Excel file?

Thank you.
Iliana Dyankova
Telerik team
 answered on 05 Feb 2015
1 answer
343 views
Hi,

I am trying to maintain state of kendo grid like Page Number,Page Size using session. I have referenced below example from your forum

http://www.telerik.com/support/code-library/save-grid-state-in-session-on-server-side

Problem is I don't have any button to Save or Load the grid state like above exmaple. 

I am saving the grid state on DataBound event of Grid and Loading the sate back from session in Document.ready function.

But its not working for me as  Index_Read function for Ajax binding of Grid  is always getting called first before LoadGridState function and thus session object is getting overridden with defualt values for pagesize, pageno etc.

Can you please help me on this.

Thanks
Aarti



Daniel
Telerik team
 answered on 05 Feb 2015
1 answer
238 views
I am having difficulty finding an example for binding the Kendo UI Grid for MVC 4 to a DataTable when using the ASPX view engine.

I reviewed the example in this forum http://www.telerik.com/support/code-library/binding-to-datatable-0191a594e359 and I am finding other examples using the Razor view engine.

Unfortunately, the MVC project to which I am assigned is very large and it is not a priority to convert to the Razor view engine at this time.  The priority is a conversion from MVC 2 to MVC 4 and it was expected the upgrade will go more quickly to stay with the ASPX view engine until a later date.

The requirements are
1. Stick with the ASPX view engine for now and 
2.  Upgrade the controls to work with MVC 4 (for this we are using the latest Kendo UI for MVC 4).

The binding scenario is to pull the DataTable from a session object called "GridResults" (That's right, it's not returned by the controller directly).

We also need to add the DataKeys to the grid when binding to the session-held DataSource.

If there are any examples of binding to a session DataSource returning a DataTable it would be appreciated.  Adding data keys would be a bonus.

Thank you
Atanas Korchev
Telerik team
 answered on 05 Feb 2015
4 answers
122 views
Hi

How do I make the listview scroll horizontally.

Thanks
Ant
Top achievements
Rank 1
 answered on 05 Feb 2015
8 answers
349 views
Hi,

I have kendogrid with list of dropdown filters. 
I am stuggling to call the javascript to load the dropdown in the ready function.
Basically I am not able to find the dropdown element in the grid so that I can call the javasript to load the dropdown again.

View Code:

  @using (Html.BeginForm("ReplaySelectedInboundMessages", "Home"))
   {
    <div id="gridContent">
       <h1></h1>  
    @(Html.Kendo().Grid<ViaPath.MessageReplay.MvcApp.Models.LogModel>(Model)
    .Name("gridTable") 
   //.EnableCustomBinding(true)
    .HtmlAttributes(new {style = "font-family: verdana,arial,sans-serif; font-size: 11px;color: #333333;border-color: #999999;"})       
    .Columns(columns => 
        {
          columns.Template(@<text><input class="box"  id="assignChkBx" name="assignChkBx" type="checkbox" value="@item.LogID"/></text>).HeaderTemplate(@<text><input class="selectAll" type="checkbox" id="allBox" onclick="toggleSelection()"/></text>).Width(20);
            //columns.Template(p => { }).ClientTemplate("<input type='checkbox' #= CheckSelect ? checked='checked':'' # class='chkbx' />");
                    
            columns.Bound(p => p.LogID).Template(p => Html.ActionLink(((string)p.LogID), "MessageDetails", new { logid = p.LogID })).Width(200);
            columns.Bound(p => p.ReceivePortName).Width(100).Filterable(ft => ft.UI("ReceivePortsFilter")); //.Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
            columns.Bound(p => p.SendPortName).Width(100).Filterable(ft => ft.UI("SendPortsFilter"));
            columns.Bound(p => p.loggedDate).Format("{0:MM/dd/yyyy hh:mm tt}").Filterable(f => f.UI("DateTimeFilter").Extra(true)).Width(100);
            columns.Bound(p => p.ControlID).Width(100);
            columns.Bound(p => p.SenderID).Width(100).Filterable(ft => ft.UI("SenderIDFilter"));
            columns.Bound(p => p.ReceiverID).Width(100).Filterable(ft => ft.UI("ReceiverIDFilter"));
            columns.Bound(p => p.InterchangeID).Width(100);
            columns.Bound(p => p.ReplayedCount).Width(100);
            columns.Bound(p => p.RetryCount).Width(100);
            columns.Bound(p => p.AckCode).Width(20);
        })
           // .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            .Filterable()
            .Pageable(page => page.PageSizes(new int[]{10,25,50,100}).Enabled(true))
            .Sortable()
            .Scrollable(src => src.Height("auto"))
            .Resizable(resize => resize.Columns(true))
            )

         <br />
        <br />
        <input type="Submit" name="btnReplayMessage" value="Replay" title="Replay Message" \>
</div>  
      <script type="text/javascript">
          function ReceivePortsFilter(element) {
              element.kendoDropDownList({
                  dataSource: {
                      transport: {
                           read: "@Url.Action("FilterMenuCustomization_ReceivePorts")"
                          
            }
        },
        optionLabel: "--Select Value--"
    });
          }



          function SendPortsFilter(element) {
              element.kendoDropDownList({
                  dataSource: {
                      transport: {
                          read: "@Url.Action("FilterMenuCustomization_SendPorts")"

                      }
                  },
                  optionLabel: "--Select Value--"
              });
          }

          function ReceiverIDFilter(element) {
              element.kendoDropDownList({
                  dataSource: {
                      transport: {
                          read: "@Url.Action("FilterMenuCustomization_ReceiverID")"

            }
        },
        optionLabel: "--Select Value--"
    });
          }

          function SenderIDFilter(element) {
              element.kendoDropDownList({
                  dataSource: {
                      transport: {
                          read: "@Url.Action("FilterMenuCustomization_SenderID")"

                      }
                  },
                  optionLabel: "--Select Value--"
              });
          }


          function DateTimeFilter(control) {
              $(control).kendoDateTimePicker();
          }

          $(document).ready(function () {
              
             
              
              
              var grid = $("#gridTable").data("kendoGrid");
              var dropdown = grid.pager.element
                               .find(".k-pager-sizes [data-role=dropdownlist]")
                               .data("kendoDropDownList");

              var item = {};
              item[dropdown.options.dataTextField] = "All";
              item[dropdown.options.dataValueField] = 1000000;
              dropdown.dataSource.add(item);

              dropdown.bind("change", function (e) {
                  if (this.text() == "All") {
                      grid.one("dataBound", function () {
                          setTimeout(function () {
                              dropdown.span.text("All");
                          });
                      });
                  }
              });
          });
      </script>
       
   }
   
   Controller Code:
   public ActionResult AllMessages([DataSourceRequest(Prefix = "gridTable")] DataSourceRequest request)
        {
            //var filterCollection = KendoGridFilterCollection.BuildCollection(Request);
            List<LogModel> logs = null;
             if (request.Filters == null)
                logs = this.GetAllMessages().Where(x => x.loggedDate >= DateTime.Today.AddDays(-7)).ToList();
             else
                 logs = this.GetAllMessages();
            
            Session.Clear();
            Session["ReceivePortsList"] = logs.OrderBy(e => e.ReceivePortName).Select(a => a.ReceivePortName).Distinct();
            Session["SendPortName"] = logs.OrderBy(e => e.SendPortName).Select(a => a.SendPortName).Distinct();
            Session["SenderID"] = logs.OrderBy(e => e.SenderID).Select(e => e.SenderID).Distinct();
            Session["ReceiverID"] = logs.OrderBy(e => e.ReceiverID).Select(e => e.ReceiverID).Distinct();

            return View(logs);
        
        }

        public ActionResult FilterMenuCustomization_ReceivePorts()
        {

            //List<LogModel> logs = this.GetAllMessages();
            //return Json(logs.Select(e => e.ReceivePortName).Distinct(), JsonRequestBehavior.AllowGet);

            return Json(Session["ReceivePortsList"], JsonRequestBehavior.AllowGet);
           
        }
Alexander Popov
Telerik team
 answered on 05 Feb 2015
3 answers
531 views
Hi Everyone --

I cannot get my Edit popup window to fire. I don't see any events happening when I debug the application. My add user function works quite well. 

Any ideas why this is?

@(Html.Kendo().Grid<
Areas.Admin.ViewModels.UserManagement.UserManagementVM>()
                .Name("UserProfileGrid")
                .Resizable(c => c.Columns(true))
                .Selectable()
                .Filterable()
                .Groupable()
             .ToolBar(toolbar =>
                    {
                        toolbar.Template(@<text>
 
 
                            <input id="ButtonAddUser" type="button" class='k-button k-grid-add' value="Add User"/>
                            <input id="ButtonEditUser" type="button" class="k-button k-grid-edit" value="Edit user" />
                             
                        @(Html.Kendo().Button()
                        .Name("ButtonRefreshPage")
                        .HtmlAttributes(new { type = "k-button" })
                        .Icon("history")
                        .Content("Refresh Page")
                        .Events(x => x.Click("RefreshPage")))
 
                        @(Html.Kendo().Button()
                        .Name("ButtonDeleteUser")
                        .HtmlAttributes(new { type = "k-button" })
                        .Icon("history")
                        .Content("Delete a user")
                        .Events(x => x.Click("DeleteUser")))
 
                        @(Html.Kendo().Button()
                        .Name("ButtonAbout")
                        .HtmlAttributes(new { type = "k-button" })
                        .Icon("history")
                        .Content("About")
                        .Events(x => x.Click("aboutButtonClick")))
                        </text>);
                    })
 
                    .Editable(editable => editable.Mode(GridEditMode.PopUp)
                    )
 
                    .Columns(columns =>
                    {
                        //columns.Bound(e => e.UserOrg).Width(25).Title("User Organization");
                        columns.Bound(e => e.IsApproved).Width(50).Title("Approved Status");
                        columns.Bound(e => e.UserName).Width(150).Title("User Name");
                        //columns.Bound(e => e.user).Width(150);
                        columns.Bound(e => e.EmailAddress).Width(150).Title("Email Address");
                    })
 
                    .Sortable()
                    .Scrollable()
                    .Pageable()
                    .Filterable()
                    .Selectable()
                    .Events(e =>
                    {
                      e.Change("packageRowSelectionChanged");
                    })
                    .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(20)
                    .Events(E => E.Error("error_handler"))
                    .Model(model => model.Id(e => e.UserId))
                    .Read(read => read.Action("ReadUsers", "UserManagement"))
                    .Create(create => create.Action("UserProfileCreator", "UserManagement"))
                    .Update(update => update.Action("UserProfileCreator", "UserManagement"))
                    .Destroy(destroy => destroy.Action("EditingPopUp_Destroy", "UserManagement"))
                    ))
Michael
Top achievements
Rank 1
 answered on 04 Feb 2015
2 answers
263 views
Hello,

I am trying to make a grid (done) having a client template (done) having a hyperlink (done). When I click on the hyperlink, it should open a window (from the suite of Telerik ASP.NET MVC controls). However, when I write the javascript function and the html within the client template, it does not function as intended.

I am not posting my code because I am interested in an example of how to do something like that. Would someone be able to post an example, please?

Just to re-coup:

1) There is a grid.
2) Within the grid, there is a column, specified by client template.
3) Within the client template, there is a link.
4) Clicking on that link should open a Telerik ASP.NET MVC window and load custom content from the server via AJAX into that window.
5) For every row of the grid, different content should be loaded into the window. The window could be re-used or specified separately for each row (preferably, reused, but any working example will do).

Thank you in advance for your help.

Alexander Popov
Telerik team
 answered on 04 Feb 2015
5 answers
86 views
The link that currently is pointing to the documentation for the Map helper returns a 404:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/map/overview

If I try looking up the documentation in the helpers list, I do not see the Map helper listed. Will this be fixed any time soon?
T. Tsonev
Telerik team
 answered on 04 Feb 2015
2 answers
94 views
Hi

I have a splitter and i'd like one of the panes to render as collapsed when the page loads? Is this easily done?

Thanks
Alex Gyoshev
Telerik team
 answered on 03 Feb 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?