There seems to be an issue with Kendo displaying data in MVC, as it is not showing any information and instead

When using Kendo, I am encountering an issue where no data is being displayed and there is just a blank row. The grid is supposed to read from a controller method that returns JSON. I have confirmed that the controller method is indeed returning valid JSON, but the grid only shows the column titles without any actual data in the rows - just one blank row. Additionally, I am seeing a ReferenceError: kendo is not defined in the console, along with a Source map error stating that the request failed with status 404. Resource URL: http://localhost:56644/Content/css/bootstrap-reboot.css Source Map URL: bootstrap-reboot.css.map

 public ActionResult GetProductsLists([DataSourceRequest]DataSourceRequest request )        
 {
       var product = (from u in this.unitOfWork.Product.Get()
              select new ProductViewModel
              {
                  product_id = u.product_id,
                  product_name = u.product_name
              });

    DataSourceResult result = product.ToDataSourceResult(request);
    var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
    jsonResult.MaxJsonLength = int.MaxValue;
    return jsonResult;
}

 <div class="row">
        <div class="col-12">
            <div id="grid class="kendo-grid-custom">
                @(Html.Kendo().Grid<ProductViewModel>()
                                        .Name("gridProduct")
                                        .Columns(columns =>
                                        {
                                            columns.Bound(c => c.product_id).Title("Product Id").Filterable(true);
                                            columns.Bound(c => c.product_name).Title("Product Name").Filterable(true)                                         
                                            .HtmlAttributes(new { style = "height: 100%;" })
                                            .TableHtmlAttributes(new { @class = "text-nowrap" })
                                            .Scrollable()
                                            .Sortable()
                                            .Filterable()
                                            .Resizable(resizable => resizable.Columns(true))
                                            .Pageable(pageable => pageable
                                            .Refresh(true)
                                            .PageSizes(true)
                                            .ButtonCount(5)
                                            .DataSource(dataSource => dataSource
                                            .Ajax().Sort(x => x.Add("product_id").Ascending())
                                            .Read(read => read.Action("GetProductList", "Product"))
                                            .Model(m =>
                                            {
                                                m.Id(i => i.product_id);
                                            }).PageSize("20"))
                )

            </div>
        </div>
    </div>

Answer №1

 public ActionResult RetrieveProductData([DataSourceRequest]DataSourceRequest request )        
   {
      var products = (from p in this.unitOfWork.Product.Get()
                  select new ProductViewModel
                  {
                      productID = p.product_id,
                      productName = p.product_name
                  });

        DataSourceResult result = products.ToDataSourceResult(request);
        var jsonResults = Json(result, JsonRequestBehavior.AllowGet);
        jsonResults.MaxJsonLength = int.MaxValue;
        return jsonResults;
    }

Update your controller method by incorporating the DataSourceRequest object and returning the JSON response.

Answer №2

Yes, I encountered a bundling issue with my Kendo references. It turns out that the incorrect path was causing my Kendo to not display any data. Once I corrected the path, everything worked smoothly:

bundles.Add(new StyleBundle("~/Content/kendo/css").Include(
            "~/Content/kendo/kendo.common.min.css",
            "~/Content/kendo/kendo.blueopal.min.css",
            "~/Content/kendo/kendo.custom.css"));

I made sure to double-check the path of the Kendo script both in the solution explorer and on my local computer.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Altering an image upon clicking solely with CSS - how is it done?

How can I display a new image below the existing one when clicked, using CSS only? Is there a simple solution for this? ...

Issues with dynamically adding or removing scroll in jQuery are not being resolved

I am trying to implement a dynamic scrolling feature in my post scenario. The goal is to automatically add a vertical scroll when the number of dynamic inputs reaches a certain threshold. Specifically, if there are more than 5 dynamic inputs created, a ver ...

Revamping the library setup for seamless integration with ASP.NET Core

We are in the process of updating our application library to be compatible with both ASP.NET Core and earlier versions of ASP.NET. Currently, our library relies on the ConfigurationManager class to retrieve settings from Web.config. Given the changes in co ...

Grails: Exploring ways to make a database request for checking updates

Is there a way for me to query my MySQL database and determine if any changes have been made, so that I can automatically refresh a specific div element if there are updates? -UPDATE- Here is the current code I am using. It simply refreshes the load func ...

Using accent marks in AJAX to retrieve information from a database

I'm currently working on compiling a list that can be found at the following link: Within the php file, I have implemented meta tags to handle accents. However, when using ajax to display search results, entering accents such as ö,ü,ő etc in the s ...

Unable to extend two components to completely occupy the width of the page

I am having difficulty ensuring that two elements occupy the entire width of the page regardless of the device size. Nav1 and Nav2 are positioned alongside each other in nav-container and will contain content. This is why I need them to be separate. I ini ...

Troubleshooting the unresponsive nature of the multi-level menu

I have incorporated a specific plugin into my application Check out my application here To access the menu, click on the third green button followed by any yellow button on the right side. However, the menu appears underneath another div rendering it unc ...

Utilizing SASS for customizable color schemes

I am in the process of creating a website using Rails 3 which will allow users to customize their profiles with different layouts and color schemes. I have already implemented SASS, and I believe it would be incredibly useful if I could achieve something l ...

Using iScroll without animation by using scrolltoelement on an iPhone PhoneGap application

I've been working on an iOS PhoneGap app that uses Backbone and some other libraries. To handle scrolling, I implemented iScroll which has been functioning properly. However, I encountered a problem with the following code snippet: events: { &apo ...

The children of the <Grid item> component in material-ui are overlapping the parent because they have a width of 100%

One issue I'm facing is that when I have children with full width in a Grid item, they end up overlapping to the right side of their parent. To illustrate this problem, here's the code: https://codesandbox.io/s/rn88r5jmn import React, { Compo ...

Is there a way to align the logo in the center vertically with the navigation on the right side of the header?

I've been grappling with this issue. I'm interested in exploring various methods to vertically center elements in navigation using semantic HTML. Specifically, I'd like my logo aligned left and the navigation menu aligned right. I attempted ...

Unable to make changes to the data

Journey Route::resource('/videofile', 'VideoController'); VideoController public function update(Request $req, $id){ $video = Video::findOrFail($id); if($req->hasFile('UserVideo')){ $vid = $req->file(& ...

Ways to update the value in localstorage with the click of a button

After a user inputs a numerical value on one screen of my web app, the value is stored in local storage. On the next screen, the user can click a button to increment the stored value by a specified amount, such as adding 5. For example, if the variable X i ...

How can I locate the CSS selector for a text message?

Looking for a CSS selector to target the message "Congratulations! displayed after successfully filling out a registration form with Selenium Web driver. Need to assert the text "Congratulations, Your email has been verified". Here is the HTML code: <d ...

Tips for effectively utilizing innerHTML in this particular scenario

For an assignment, we were tasked with creating a Madlib game where users input words into textfields to replace certain words in a hidden paragraph within the HTML using JavaScript and CSS. The paragraph embedded in the HTML page is as follows: <span ...

Jumping panel.css transition

I'm trying to create a simple bounce card animation, but I've run into an issue where the animation resets and doesn't flow smoothly. Could you take a look at this code snippet: div{ width: 110px; height: 50px; back ...

Ensuring Input Accuracy with jQuery Form Validation

I have implemented a form validation code that is currently functioning correctly. Below is the snippet of the code I used: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> <script ...

Internet Explorer is not recognizing the max-width property as expected

Every time I adjust the max-width setting, I see no difference. It was working fine before, but now it's not changing anything. I must be missing something simple or maybe a semicolon somewhere. CSS isn't my strong suit, but I'm trying to le ...

Create identical buttons using Bootstrap 4

I am trying to create uniform left and right buttons, but I am facing issues with making them look the same on both PC and mobile devices. Here is the current appearance: View the current button design <h3> <a href="" ...

"Troubleshooting: jQuery addClass Function Unable to Locate Specific Class by

I'm facing an issue where a class applied only to an ID is not being found when using addClass in my JavaScript. The JS code is working and adding the class, but it seems like the CSS class is not being found. Could there be a mistake in how I am addi ...