Telerik Forums
UI for ASP.NET MVC Forum
1 answer
936 views
Hi,

Do you have sample code for selecting, then copying and pasting the selected rows to other rows in the kendo ui asp.net mvc grid

Thanks,
Annie
Dimo
Telerik team
 answered on 14 Oct 2014
2 answers
205 views
I have the following Grid:

@(Html.Kendo()
    .Grid<IncidentBreakdownViewModel>()
    .Name("Grid")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(true)
        .Read(x => x.Route("PostReadJson", new { incidentId = Model.IncidentId }))
        .Create(x => x.Route("PostCreateJson", new { incidentId = Model.IncidentId }))
        .Destroy(x => x.Route("PostDeleteJson", new { incidentId = Model.IncidentId }))
        .Update(x => x.Route("PostUpdateJson", new { incidentId = Model.IncidentId }))
        .Model(model => model.Id(x => x.IncidentBreakdownId)))
    .Columns(columns =>
        {
            columns
                .ForeignKey<int?>(
                         x => x.IncidentBreakdownTypeId,
                         (SelectList)ViewBag.IncidentBreakdownTypes)
                .Width(50);
            columns.Bound(x => x.PortfolioId).Width(150);
            columns.Bound(x => x.Currency).Width(100);
            columns.Bound(x => x.ErrorAmount).Width(50);
            columns
                .Bound(x => x.PaymentRequired)
                .ClientTemplate("#= PaymentRequired ? 'Yes' : 'No' #")
                .Width(50);
            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(60);
        })
    .ToolBar(toolbar => toolbar.Create().Text("Add new breakdown"))
    .Editable(x => x.Mode(GridEditMode.InLine))
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Sortable(x => x.SortMode(GridSortMode.MultipleColumn))
    .Navigatable())

The first column (IncidentBreakdownTypeId) is a drop down with two columns. I want the second column (PortfolioId) to be a different drop down depending on the selected value of the first column (IncidentBreakdownTypeId) and I want to use an AJAX Kendo ComboBoxFor for the second column like so:

<script>
    function onGetClientData() {
        return {
            text: $("#PortfolioId").data("kendoComboBox").text()
        };
    }
</script>
 
@(Html.Kendo()
    .ComboBoxFor(x => x)
    .Name("PortfolioId")
    .DataTextField("Text")
    .DataValueField("Value")
    .Filter(FilterType.Contains)
    .DataSource(dataSource => dataSource
        .Read(x => x
            .Route("GetClientsJson")
            .Data("onGetClientData"))
        .ServerFiltering(true)))

How can I achieve this?
Daniel
Telerik team
 answered on 14 Oct 2014
2 answers
758 views
Hi,

I'm a longtime user of the UI for ASP.NET AJAX. I recently grabbed the demo of the UI for ASP.NET MVC and started playing around with it as I have a need for using MVC.

I have a toolbar on a page defined as follows:
@(Html.Kendo().ToolBar()
    .Name("toolbar")
)

I have a script that is calling a controller to load information on what toolbar items should be made available:
<script>
    $(document).ready(function() {
        $.post("/FileReview/DisplayToolbar/" + @ViewBag.FileReviewID + "/", function(buttonsToAdd) {
            var toolbar = $("#toolbar").data("kendoToolBar");
 
            for (var i = 0; i < buttonsToAdd.length; i++) {
                toolbar.add({
                    type: "button",
                    text: buttonsToAdd[i].Text,
                    imageUrl: buttonsToAdd[i].ImageUrl,
                    url: buttonsToAdd[i].NavigateUrl,
                    click: buttonsToAdd[i].ClickAction
                });
            }
        });
    });
</script>

The controller builds an array of ToolBarButtonModel:
public class ToolBarButtonModel
{
    public string Text { get; set; }
 
    public string ImageUrl { get; set; }
 
    public string ClickAction { get; set; }
 
    public string NavigateUrl { get; set; }
}

This works great for buttons that use the NavigateUrl. Buttons that use the click action are not working. I am guessing it is because I am passing a string of the function name to be called when adding the button on client side (the function to be called exists on the view already). It seems I must add a direct reference to a function here. Is there a way I can do this? Or perhaps there is a better approach for dynamically adding toolbar buttons?

Alexander Valchev
Telerik team
 answered on 13 Oct 2014
7 answers
205 views
I have no idea what I am missing here, but no matter what I try, I cannot get the count to be accessible using #=count#  I have this working with JavaScript by using a function to return the count but this count should be accessible according to the demo examples which I have been over many times, and cannot see my mistake. Calling the "#=ClockInStatusString(data)#" and  #=groupHeaderString(data)# works fine, the proper data is returned.

<div>
            @(Html.Kendo().Grid<viewmodel>()
          .Name("CampaignGrid")
          .Columns(columns =>
          {
              columns.Bound(c => c.FirstName).Sortable(true);
              columns.Bound(c => c.LastName);
              columns.Bound(c => c.ClockInDate);
              columns.Bound(c => c.ClockInTime);
              columns.Bound(c => c.ClockInStatus).ClientTemplate("#=ClockIStatusString(data)#").ClientGroupHeaderTemplate("#=groupHeaderString(data)# #=count#");
              columns.Bound(c => c.Campaign).ClientGroupHeaderTemplate("(Agents Count: #=count# )"); ;
              columns.Bound(c => c.UserName).ClientTemplate("<a href='/User/GetUserHistory/#= UserName#'>Activity</a>");
          })
          .Sortable(sort => sort.Enabled(true))
          .DataSource(datasource => datasource
              .SignalR()
              .Aggregates(aggregates =>
              {
                  aggregates.Add(c => c.ClockInStatus).Count();
                  aggregates.Add(c => c.Campaign).Count();
              })
              .Group(groups =>
              {
                  groups.Add(model => model.ClockInStatus);
                  groups.Add(model => model.Campaign);
              })
              .Transport(tr => tr.Promise("hubPromise")
                  .Hub("hub")
                  .Server(server => server
                      .Read("getClockedInUsers")
                      .Update("update")
                      .Destroy("desstroy")
                      .Create("create")))
              .Schema(scheme => scheme
                  .Model(model =>
                  {
                      model.Id(c => c.UserId);
                      model.Field(c => c.FirstName);
                      model.Field(c => c.LastName);
                      model.Field(c => c.ClockInDate);
                      model.Field(c => c.ClockInTime);
                      model.Field(c => c.Campaign);
                      model.Field(c => c.ClockInStatus);
                      model.Field(c => c.UserId);
                  }))
              )
            )
        </div>

Any help would be appreciated!
Thanks!

Vladimir Iliev
Telerik team
 answered on 13 Oct 2014
4 answers
1.6K+ views
has anyone had any success with the following?? the function does not get called. Thank you!

      .Editable(editing => editing.Mode(GridEditMode.PopUp).Window(w => w.Events(e => e.Close("OnClose"))))
Vladimir Iliev
Telerik team
 answered on 13 Oct 2014
1 answer
183 views
Hi:
Is there any way to export to Excel from the Kendo Grid without using open source tools like NPOI?
Thanks.
Atanas Korchev
Telerik team
 answered on 13 Oct 2014
1 answer
638 views
Hi -

I have the grid below and am trying to get the value of a certain column to dynamically render a set of workflow buttons based on that value.  Is it possible to do this?


Html.Kendo().Grid<ViewModelName>()
   .Name("GridName")
   .ToolBar(commands => commands.Create())
   .DataSource(ds => 
  ds.Ajax()
  .Read("Select", "EmpActivitySummary", new { EmpActivityId = RouteData.Values["id"] })
  .Update("Update", "EmpActivitySummary", new { EmpActivityId = RouteData.Values["id"] })
  .Destroy("Delete", "EmpActivitySummary")
  .Create("Insert", "EmpActivitySummary", new { EmpActivityId = RouteData.Values["id"] })
  .Model(m =>
  {
  m.Id(x => x.Id);
  m.Field(x => x.EmpActivityId).Editable(false);
  m.Field(x => x.Id).Editable(false);
  m.Field(x => x.Approved).Editable(false);
  })
   )  
   .PrefixUrlParameters(false)
   .Columns(r =>
   {           
r.Command(com =>
{
com.Edit();
com.Destroy();

var currentStatus = r.Template(model => model.Approved);  // <--------------- I'm trying to get the value of this column
var utilities = new WorkflowUtilities("Workflow Name");
var steps = utilities.GetSteps(currentStatus);

foreach (var step in steps.Where(step => Roles.IsUserInRole(step.RequiredRole)))
{
com.Custom(step.ButtonText).Click("ProcessWorkflowStep").SendDataKeys(true);                        
}

}).Title("Commands").Width(60);
r.Bound(x => x.Id).Width(100);
r.Bound(x => x.Field);
r.Bound(x => x.Quantity);
r.Bound(x => x.Price).AsCurrency();
r.Bound(x => x.Date);
r.Bound(x => x.Approved);
    
   })
   .Render();
Dimiter Madjarov
Telerik team
 answered on 10 Oct 2014
1 answer
79 views
Hi,

How to export to excel after having re-ordered the columns, with the new column order

Thanks,
Annie
Atanas Korchev
Telerik team
 answered on 10 Oct 2014
1 answer
156 views
Hi There,

I am facing an issue when trying to use multi-select control in grid filter.

I have gone through the following link - http://www.telerik.com/forums/multi-select-in-grid-filter-template

The UI of multiselect does not persist the value when I filter the multiselect column and go to some other column and filter it and come back to multiselect column it does not display values on UI but it retains the values on multiple columns search with other filters.

It works when I remove data-bind but I cannot apply filter simultaneously with other filters.

Please help me to achieve both persistent search and filtering multiple columns simultaneously.

Petur Subev
Telerik team
 answered on 10 Oct 2014
1 answer
107 views
Hi,

I am using kendoGrid() to display data, which receives from database in MVC model.

In this kendoGrid, we included "Edit" feature given by kendoGrid.  But when trying to update the data,  the cursor is going into the controller, but the parameter(model) for that action contains null data. i.e. the data is not getting posted from view to controller.

for your reference, I have attached the code files.

Thanks in advance.

Swarnalatha
Alexander Popov
Telerik team
 answered on 09 Oct 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
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
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?