Telerik Forums
UI for ASP.NET Core Forum
1 answer
497 views

Hi,

I have a grid with a details template. I want to hide a column in the details template based on the value of a column from the main grid. Is this possible?

Thanks,

Cornel.

Stefan
Telerik team
 answered on 06 Dec 2017
3 answers
429 views

Hi,

I'm currently validating the UI for ASP.NET Core grid component and I run into an issue with the WebApi datasource. When trying the fetch the data it tries to find the data on endpoint "localhost:50050/Customers" however the endpoint is located at the endpoint "localhost:50050/api/Customers". I am following the examples listed here: "http://demos.telerik.com/aspnet-core/grid/webapi". In the demo the route is also configured at "api/{controller}".

Is there any special route configuration I need to add somewhere?

My "Index.cshtml" looks like:

<div class="main">
    @(Html.Kendo().Grid<Customer>()
        .Name("customerGrid")
        .Columns(columns =>
        {
            columns.Bound(c => c.Id).Title("Tenant");
            columns.Bound(c => c.CompanyProfile.CompanyName).Title("Naam");
            columns.Bound(c => c.CompanyProfile.Domain).Title("Domein");
            columns.Bound(c => c.RelationshipToPartner).Title("Relatie");
        })
        .Scrollable()
        .Groupable()
        .Sortable()
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .DataSource(dataSource => dataSource
            .WebApi()
            .Model(model =>
            {
                model.Id(c => c.Id);
            })
            .Read(read => read.Action("Get", "Customer"))
        )
    )
</div>

My controller class:

public class CustomerController : Controller
{
    private readonly IAuthenticationService _authenticationService;
    private readonly ICustomerService _customerService;
    private readonly ISubscriptionService _subscriptionService;
    private readonly IUsageService _usageService;
 
    public CustomerController(
        IAuthenticationService authenticationService,
        ICustomerService customerService,
        ISubscriptionService subscriptionService,
        IUsageService usageService
        )
    {
        if(authenticationService == null)
            throw new ArgumentNullException(nameof(authenticationService));
        if (customerService == null)
            throw new ArgumentNullException(nameof(customerService));
        if (subscriptionService == null)
            throw new ArgumentNullException(nameof(subscriptionService));
        if(usageService == null)
            throw new ArgumentNullException(nameof(usageService));
 
        _authenticationService = authenticationService;
        _customerService = customerService;
        _subscriptionService = subscriptionService;
        _usageService = usageService;
    }
 
    // GET: /<controller>/
    public IActionResult Index()
    {
        return View();
    }
 
    [HttpGet, Route("api/Customers")]
    public async Task<object> Customers([DataSourceRequest]DataSourceRequest request)
    {
        var customers = await _customerService
            .GetCustomersAsync();
 
        return new { data = customers, totalCount = customers.Count };
    }
}

 

 

Stefan
Telerik team
 answered on 04 Dec 2017
5 answers
520 views

I am using Telerik Grid for Aspnet Core 2.0, but here my Actionresult "[DataSourceRequest]" can't be called, the browser says error message "The connection was reset".

Please find my code below:

Index.cshtml

-----------------

@(Html.Kendo().Grid<MVC6.Models.Blog>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.Title).Width(140);
            columns.Bound(c => c.Description).Width(190);
        })
        .HtmlAttributes(new { style = "height: 380px;" })
        .Scrollable()
        .Groupable()
        .Sortable()
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Customers_Read", "Blogs"))
        )
)

BlogController.cs

-----------------------------------

// GET: Blogs
        public async Task<IActionResult> Index()
        {
            return View("~/Views/Home/Index1.cshtml");
        }

        public IActionResult Customers_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetBlogs().ToDataSourceResult(request));
        }

        private  IEnumerable<Blog> GetBlogs()
        {
            return _context.Blog.Select(blog => new Blog
            {
                Title = blog.Title,
                Description = blog.Description

            }).ToList();
        }

Stefan
Telerik team
 answered on 01 Dec 2017
2 answers
119 views

While populating a ComboBoxFor to be inside a grid, if the name of the view data variable is the same as the id, validation will be ignored.

View:

columns.ForeignKey(p => p.JobNo, (System.Collections.IEnumerable)ViewData["JobNo"], "JobNo", "JobNumber");

Controller:

public IActionResult Index()
       {ViewData["jobnumber"] = _ddservice.GetAllOrdersByOfficeIdDD(oid);
           return View();
       }

 

Stefan
Telerik team
 answered on 27 Nov 2017
3 answers
1.2K+ views

Hello,

I have the following grid with columns.AutoGenerate(true) :

@(Html.Kendo().Grid<dynamic>()
      .Name("gridEQ")
      .Columns(columns =>
      {
          columns.AutoGenerate(true);
      })
      .Pageable()
      .Sortable()
      .Scrollable()
      .Selectable(s => s.Mode(GridSelectionMode.Multiple))
      .NoRecords()
      .Filterable(f => f.Enabled(false))
      .AutoBind(false)
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(100)
          .Read(read => read.Action("Read", "Home"))
      )
    )

 

If there is a query result from SQLServer with a column Name with spaces no rows are shown in the grid (the column Header is there)
see attached Picture

here is the json result:

{"Data":[{"Anzahl der Betriebsmittel":1376}],"Total":1,"AggregateResults":null,"Errors":null}
Viktor Tachev
Telerik team
 answered on 24 Nov 2017
1 answer
117 views

Hi - I'm trying to filter a grid that is bound to child tables using .Include() and .IncludeNext() and having no luck. I keep getting the error below - any help would be appreciated, I tried just about everything including gathering up all the SerialNumbers at a higher level but that was flakey code and causing a performance degradation.

Message"Invalid property or field - 'SerialNumber' for type: Invoice"string

Here's my data load statement:

invoices = from inv in _context.Invoices.Include(i => i.ShippingAddress).Include(i => i.InvoiceLines).ThenInclude(s => s.SerialNumbers)    
                       where orgIds.Contains(inv.OwnedBy_Id) select inv;

And my filters:

$("#Grid").data("kendoGrid").dataSource.filter({
            logic: "or",
            filters: [
                {
                    field: "SerialNumber",
                    operator: "contains",
                    value: searchValue
                },

Thanks!
Craig

Konstantin Dikov
Telerik team
 answered on 24 Nov 2017
1 answer
301 views

Hello,

 

I saw the demo here: http://demos.telerik.com/aspnet-core/grid/checkbox-selection

I'm trying to do the same, but I can't get it to work.
this is my code: 

 

       @(Html.Kendo().Grid<CalculationResultModel>()
.Name("Grid")
.Columns(columns =>
{
    columns.Select().Width(50);
   ...
})
.Events(ev => ev.Change("onChange"))
   .DataSource(dataSource => dataSource
     .Ajax()
     .ServerOperation(true)
     .Model(model => model.Id(m => m.CalculationRequestIdentification))
     .Read(read => read.Action("x", "x").Type(HttpVerbs.Get))

     )
        )

when I call the selectedKeyName() function in the javascript, I get an empty array.

Any Idea why that can be? The Id is a Guid btw.

 

Thanks!

 

 

Steven
Top achievements
Rank 1
 answered on 22 Nov 2017
10 answers
696 views

Hello,

I'm having some grid's - some with paging or grouping (Expanded and Collapsed) where I want to search for a specific row (Model_Id) and

select that row (if it is a grouped row it should be expand)...

  • I know that I can get the dataitem with
var dataItem = $("#grid").data("kendoGrid").dataSource.get(id);

but does this work also in a paged grid?

  • If I find the row how to select this row if it is on another page?
  • If I select the row and it is in a Group which is colapsed - how to expand that Group?

robert

 

 

 

 

Robert Madrian
Top achievements
Rank 1
Veteran
Iron
 answered on 22 Nov 2017
2 answers
151 views
I'm having some troubles trying to display events in the Scheduler, maybe casued by DateTime format.

My scheduler configuration is the following:

@(Html.Kendo().Scheduler<BookingSchedulerDto>()
    .Name(“Scheduler")
    .Date(DateTime.Now)
    .StartTime(Model.Start)
    .EndTime(Model.End)
    .Editable(m => m.TemplateId("editor"))
    .Views(views =>
    {
        views.DayView(view => view.Selected(true));
        views.WeekView();
        views.MonthView();
        views.AgendaView();
    })
    .Timezone("Etc/UTC")
    .DataSource(d => d
        .Events(e =>
        {
            e.Error("onError");
        })
        .Model(m =>
        {
            m.Id(f => f.Id);
            m.Field(f => f.Start);
            m.Field(f => f.End);
            m.Field(f => f.Title).DefaultValue("Nessun titolo");
            m.Field(f => f.IsAllDay).DefaultValue(false);
            m.Field(f => f.Name);
        })
        .Create("Update", "Booking")
        .Read("Read", "Booking")
        .Update("Update", "Booking")
        .Destroy("Delete", "Booking")
    )
)

where the Model.Start and Model.End are DateTime types. 
The BookingSchedulerDto entity properties Start and End are also DateTime objects. An example of result of read method is
[
  {
   â€¦,
    "StartTimezone": "Etc/UTC",
    "EndTimezone": "Etc/UTC",
    "RecurrenceRule": null,
    "Start": "2017-11-07T20:16:54.073+01:00",
    "End": "2017-11-07T23:16:54.073+01:00",
    "Id": 4,
   â€¦
  },
  {
      …
  }
]

The problem here is that events are not rendered in the scheduler as expected. What am I doing wrong? Is the result date format correct? Any other causes?
Davide Vernole
Top achievements
Rank 2
 answered on 21 Nov 2017
1 answer
335 views

Dear All,

Can you help me :)

I want to get value from dropdownlist in popup in grid.I have dropdownlist TransactionId,i want get automactically value in field outstanding Amount whatever in transaction id is primary key from outsatnding amount. 

 

My view:

<div>
    @(Html.Kendo().Grid<DevRedsMk3.Models.NpvCalculation>()
        .Name("NpvCalculation")
        .Columns(columns =>
        {
            columns.Bound(p => p.NpvCalculationId).Hidden();
            columns.ForeignKey(p => p.TransactionId, (System.Collections.IEnumerable)ViewData["custTrans"], "TransactionId", "TransactionId").Title("TransactionId ID");
            columns.Bound(p => p.LastPayment).Title("Last Payment");
            columns.Bound(p => p.OutstandingAmount).Title("Outstanding Amount");
            columns.Bound(p => p.Installment).Title("Installment");
            columns.Bound(p => p.Interest).Title("Interest");//Title("Interest").Editable(false)

            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150);
            columns.Command(c => c.Custom("OK").Text("OK").Click("OK"));
        })
        .ToolBar(toolbar =>
        {
            toolbar.Create();
        })
        .Events(e => {  e.DataBound("onchangeevent"); })
        .Editable(editable => editable.Mode(GridEditMode.PopUp))
        .Scrollable(s => s.Height(570))
        .Sortable()
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .DataSource(datasource => datasource
             .Ajax()
             .ServerOperation(false)
             .Model(model =>
             {
                 model.Id(p => p.NpvCalculationId);
                 model.Field(p => p.Interest).Editable(false);

             })

             .Read(read => read.Action("List", "NpvCalculations"))
             .Update(update => update.Action("Update", "NpvCalculations"))
             .Create(create => create.Action("Create", "NpvCalculations"))
             .Destroy(destroy => destroy.Action("Destroy", "NpvCalculations"))

        )
    )

    <script type="text/javascript">
        function OK(e) {
            e.preventDefault();
            var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
            
            $.ajax({
                url: "/NpvCalculations/GenerateNpvBaru",
                //data: dataItem.id,
                //data: { 'TransactionId': dataItem.TransactionId },
                data: { TransactionId: dataItem.TransactionId },
                success: function (response) {
                    //$('#viewDetails').html(response);
                    //alert('Approve done...');
                }
            });
        }
    </script>

    <script>
        function onchangeevent() {
            $('#OutstandingAmount').val('10000');
        }

    </script>

</div>

 

 

Thanks for your help,

 

Regards,

 

Madeck

Stefan
Telerik team
 answered on 20 Nov 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?