Template is not yet rendered when the client side event for "Create" is called

I have an EJGRID in my ASP NET MVC 5 web app. 

  • I have a grid with a column which has the following template
<script id="DescriptionColumnTemplate" type="text/x-jsrender">
    <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
        <input type="checkbox"  class="js-addendum-grid-checkbox">
    </label>
</script>

  • I have added the following for capturing the "Create" client side event
.ClientSideEvents(eve =>
{
     eve.Create("onActionComplete");
})
  • The JavaScript function does the following:
function onActionComplete(args) {
    console.log($(".js-addendum-grid-checkbox").length);
}

When displayed the Grid has more than one row displayed. Each row having a checkbox with the css class "js-addendum-grid-checkbox" as in the above template. But the the "onActionComplete" function is called, no checbox is found in the grid. 

QUESTION: When the client side event is called, the template for the column is not rendered yet?

5 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team May 21, 2020 12:27 PM UTC

Hi Suraj, 

Thanks for contacting Syncfusion Support. 

Query#:- when the client side event is called, the template for the column is not rendered yet? 

We have prepared sample as per your code example but we are unable to reproduce the problem(Create event triggered) at our end. Refer to the sample Link:- 

Refer to the Demo and Documentation Link about ColumnTemplate:- 

Ensure that you have followed the sample and Demo properly. We need some more additional details to find the cause of the issue. Share us the following details. 

  1. Complete Grid code example(Client and Server).
  2. Screenshot/Video Demo to replicate the issue.
  3. Is checkbox render at your end in Template column. Share Screenshot.
  4. Product version details.

Regards, 
Farveen sulthana T 



SA Support Arcania May 26, 2020 04:06 PM UTC

Thanks for the response. In the example you gave me the code works fine. But in my scenario, the grid datasource loads from a URL. I have attached the modified version in the attachement.
  • I have added a new action "GetGridData" to return the list of Orders. => See the attached file GridController.cs
  • I have changed the DataSource to fetch the data from the Grid/GetGridData => See the attached file GridFeatures.cshtml
If you run the sample solution with the provided modified files you will be able to reproduce my error. You will notice that you will get a count of 0 even if the grid is loaded with 99 items.
Thanks in advance.

Attachment: ModifiedFiles_3b13ddb7.zip


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team May 27, 2020 02:20 PM UTC

Hi Arcania, 

Query#:- You will notice that you will get a count of 0 even if the grid is loaded with 99 items. 

We are able to reproduce the problem at our end from your given code example. In your provided code example, you have bind RemoteData for Grid dataSource. While using Remote data, data doesn’t bound to the Grid on Create event. So the reported problem occurs. In order to get the data and template elements we suggest you to use DataBound event of the Grid which triggers after the data is bound to the Grid. 

Refer to the code example:- 

@(Html.EJ().Grid<OrdersView>("FlatGrid") 
                //.Datasource((IEnumerable<object>)ViewBag.datasource) 
                .Datasource(ds => ds.URL(Url.Action("GetGridData", "Grid")) 
                .Adaptor(AdaptorType.UrlAdaptor)) 
        .ClientSideEvents(eve => 
        { 
            eve.DataBound("onDataBound"); 
        }) 
        .IsResponsive() 
        .Columns(col => 
        { 
            .   .   . 
       })) 
 
<script type="text/javascript"> 
    function onDataBound(args) { 
        console.log($(".js-addendum-grid-checkbox").length); 
    } 
</script> 

Refer to the API Link:- 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 



SA Support Arcania May 28, 2020 03:39 PM UTC

Thank you for the response. The proposed solution worked fine. :)


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team May 29, 2020 04:24 AM UTC

Hi Arcania, 

Thanks for your update. Please get back to us if you need any further assistance on it. We are happy to assist you. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon