Table ID in event object

6 posts, 1 answers
  1. Erik Stell
    Erik Stell avatar
    11 posts
    Member since:
    Dec 2013

    Posted 26 Mar 2014 Link to this post

    Prior to the recent 2014.1.318 release, it was possible to obtain the id of a table in the event object in javascript, like so:

    function DoSomethingForThisTable(e){
        var id = e.sender.options.table.context.id;
        //get the table with this id and do things
    }

    However, after the release, this process fails, as the table object on the e.sender.options is now always null.  Is there an alternative to doing this, or is this a bug?

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 28 Mar 2014 Link to this post

    Hi Erik,

    From the provided information it's not clear for us what is the exact scenario that you have nor what is the event that you are referring to - could you please small runable example where the issue is reproduced? 

    Regards,
    Vladimir Iliev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Erik Stell
    Erik Stell avatar
    11 posts
    Member since:
    Dec 2013

    Posted 28 Mar 2014 in reply to Vladimir Iliev Link to this post

    A modified version of one of your own examples:

    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()   
        .Name("grid")
        .Columns(columns => {
            columns.Bound(p => p.OrderID).Filterable(false).Width(100);
            columns.Bound(p => p.Freight).Width(100);
            columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}").Width(140);
            columns.Bound(p => p.ShipName);
            columns.Bound(p => p.ShipCity).Width(150);
        })
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .HtmlAttributes(new { style = "height:430px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Events(e => e.RequestStart("ActivateBusyMode"))
            .PageSize(20)
            .Read(read => read.Action("Orders_Read", "Grid"))
         )

    Event Function:
    function ActivateBusyMode(e) {
        try{
            kendo.ui.progress($("#" + e.sender.options.table.context.id + " div.k-grid-content:first"), true);
        } catch (er) {
            alert("Fail!");
        }
    }
     
    Before the 2014.1.318 release, the e.sender.options.table.context.id path would return the ID of "grid".  As of now, the e.sender.options.table value is always null, which errors out the process.
  5. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 31 Mar 2014 Link to this post

    Hi Erik,

    Please note that the current behavior is expected and intended - the DataSource shouldn't know about the widgets that are using it as single DataSource can be used by several widgets. Previously the Grid table was accessible in the DataSource due to bug which is fixed in the latest official release. 

    Possible solution to access the Grid from it's DataSource events is to use anonymous function which to pass the name of the Grid as demonstrated in the following example:

    .DataSource(dataSource => dataSource       
        .Ajax()  
        .Events(e => e.RequestStart(@<text>
            function(e) {
                ActivateBusyMode(e, 'grid');
            }
        </text>))

    function ActivateBusyMode(e, gridName) {
        try {
            kendo.ui.progress($("#" + gridName + " div.k-grid-content:first"), true);
        } catch (er) {
            alert("Fail!");
        }
    }

    Regards,
    Vladimir Iliev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  6. Mike
    Mike avatar
    7 posts
    Member since:
    Nov 2008

    Posted 23 Apr 2014 in reply to Vladimir Iliev Link to this post

    Want to disagree with the assertion that the datasource, as being consumed in events triggered by a widget should not know about the widget.
    In fact it makes perfect sense that the datasource should be fully informed of the widget currently consuming it and ultimately responsible for triggering the event.

    At the very least this change should be noted as a 'breaking change', since it does seem many people were depending upon it, myself included.
    The proposed workaround seems kludgey in comparison.
  7. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 24 Apr 2014 Link to this post

    Hi Erik,

    If you believe that current behavior is not correct I would suggest to share your idea at KendoUI UserVoice to allow other users vote, evaluate and comment on it. Most voted ideas are included in next KendoUI releases.

    Regards,
    Vladimir Iliev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready