UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Telerik Kendo Grids    
 
   
LeeAnn
post May 1 2020, 01:44 PM
Post#1



Posts: 1,303
Joined: 2-February 00
From: Mississippi USA Central Time Zone


Maybe someone here can point me to the right direction, I have went to every other place. I am trying to work with a Teleriik Grid in an MVC application and I am seriously stuck. I have a grid that is set and looks beautiful but for one thing, I cannot for the life of me figure out how to get the data from the database to the view. The headers look really great but there is no data. I know that I need to get add something to the controller but I do not know what. Here is what I have in the view. I know I probably will not get any assistance on this from here but I have looked everywhere else and I have received information overload. So I am taking a long shot that maybe I can hey help:

CODE
<p>
    @Html.ActionLink("Create New", "Create")
</p>
@(Html.Kendo().Grid<CertificateTrackingSystem.Models.Status>
            ()
            .Name("StatusGrid")
            .Columns(columns =>
            {
                columns.Bound(c => c.StatusID)
                .Visible(false).IncludeInMenu(true)
                .Title("ID").Width(30);
                columns.Bound(c => c.Status.NameofStatus)
                .Title("Status Name").Width(70);
                                //columns.Command(commands =>
                //{
                //    commands.Edit().Text(" ".).UpdateText(" ").CancelText(" ");
                //    commands.Destroy().Text(" ");


                //}).Title("Actions").Width(150);


            }
            )
            .Filterable(ftb => ftb.Mode(GridFilterMode.Menu))
            .DataSource(dataSource =>
            dataSource.Ajax()
            .Sort(sort => sort.Add("Status").Descending())
            .Model(model =>
            {
                model.Id(Status => Status.StatusID);
                model.Field(Status => Status.NameofStatus).Editable(false);
                            }

    )
    )
//.Events(e => e.sync("sync_handler"))
//   .Create(create => create.Action("AddComments", "Document", new { areas = "Document", docID = @documentID, docRev = @documentRev }).Data("GetRequestToken"))
// .Read(read => read.Action("ReadComments", "Document", new { areas = "Document", documentID = @documentID, documentRev = @documentRev }).Type(HttpVerbs.Get))
// .Update(update => update.Action("UpdateComments", "Document",new { areas = "Document" }).Data("GetRequestToken"))
// .Destroy(destroy => destroy.Action("DeleteComments", "Document", new { areas = "Document"}).Data("GetRequestToken"))
// .PageSize(5)
// .ServerOperation(false)

//.Pageable(x => x.PageSizes(new List<object> { 5, 10, 20, 50, "all" }).Refresh(true))
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Comments"))
//.Sortable()



)

This post has been edited by LeeAnn: May 1 2020, 01:46 PM

--------------------
Lee Ann Davidson
Go to the top of the page
 
ChromaticZero
post May 6 2020, 12:41 AM
Post#2



Posts: 27
Joined: 7-September 15



Hi LeeAnn,

This is a bit difficult to troubleshoot without a deeper look at what's going on with the entire application, and there are a lot of areas that could be causing you problems. I suppose I would have several questions for you to start digging into this -

1. Is this the only grid you currently have hooked up in your application? I ask because if you have another grid and it's working, it would be a great place to look and determine where you might be going wrong.

2. Can you confirm that data is being passed between your database and your application with the controller? Essentially, your controller should be 'fetching' the data from your database and presenting it to your view. If it's not making it to the controller, that would be where I might start to troubleshoot the problem.

3. Judging by the code you've provided, it appears to me that your DataSource is lacking a proper Ajax call. The Ajax call should be where the GET request is sent. It would/should look something like this (example code only):
CODE
$.ajax({
    type: "POST",
    URL: '@URL.Action("Search")',
    data: JSON.stringify({ id: id }),
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    success: function (result) {
        var grid = $("#Grid").data("kendoGrid");
        var data = new kendo.data.DataSource(result);
        grid.dataSource.data(data);
        grid.refresh();
    }
});


You should definitely be checking out the Telerik whitepages on how to hook this up properly in an MVC architecture. Unfortunately for you, the work I do with Kendo is MVVM so I'm unfamiliar with the proper syntax and hookup that you're looking for. Hopefully this will at least get you started in the right direction.
Go to the top of the page
 
LeeAnn
post May 8 2020, 09:11 AM
Post#3



Posts: 1,303
Joined: 2-February 00
From: Mississippi USA Central Time Zone


Thanks for your assistance. The issue I think is that in a grid you can only pull from one model (forgive me if that is incorrect but from what it looks to me that is what I am seeing). When I took the grid and just showed the fields from my main table the data came up fine. So now I am looking at trying to make dropdown list. When I create a dropdown list all I see is a bunch of blank text boxes unless I edit the record, then I see the numerical value of the record. I click update and sometimes it turns into a dropdown but then if you hit edit again it turns right back into a text box. I am not too happy with grids as it seems if I solve one issue another one comes up. I am getting too old to learn new stuff I feel, especially stuff that is so hard to work with. I do admit though the grids look good.....

Thanks again for the help.


--------------------
Lee Ann Davidson
Go to the top of the page
 
ChromaticZero
post May 27 2020, 11:40 AM
Post#4



Posts: 27
Joined: 7-September 15



Hi LeeAnn,

I saw this after I sent you a PM in regards to the issue. This give a bit more context to what you're dealing with.

Again, I would recommend you check out the Telerik whitepapers on this (https://demos.telerik.com/aspnet-mvc/dropdownlist) but I might be able to help you get going in the right direction.
The grid will have it's own model to work with, this should be organized and passed via the controller. Likewise, the dropdown list will also require it's own DataSource in order to determine what values can be selected and which selected value should be saved to the field. Refer to the whitepaper to understand how that works.

In regards to the Edit issue, it may be that your grid is configured in a particular way that you don't find appealing and it may be that you want to configure it for Inline editing.
Here is an example for the MVC Grid : https://demos.telerik.com/aspnet-mvc/grid
Here is an example for editing Inline : https://demos.telerik.com/aspnet-mvc/grid/editing-inline

Without more information on what you're doing and what you're trying to achieve, I won't be able to help you. If you can post your code, I might be able to provide you more assistance.

Good luck!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    29th May 2020 - 04:38 AM