We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hide Selected Rows - Client Side in Asp.net Core

Thread ID:

Created:

Updated:

Platform:

Replies:

151246 Jan 31,2020 06:25 PM UTC Feb 6,2020 06:05 AM UTC JavaScript - EJ 2 5
loading
Tags: Grid
Abaid-ur-Rehman Zulfi
Asked On January 31, 2020 06:25 PM UTC

Hi,

I was looking a way to hide rows using JavaScript in ASP.net core but couldn't find working code. The closes match is here https://www.syncfusion.com/forums/140765/how-to-hide-a-row-in-the-grid-client-side but code doesn't work in asp.net core 2.2

<script type="text/javascript"> 
 
    function hiderow(args) { 
 
        var obj = $(".e-grid").ejGrid("instance"); 
        var row = obj.getSelectedRows(); 
        row.hide(); 
    } 
</script> 


Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On February 3, 2020 03:48 PM UTC

Hi Abaid, 

Thanks for contacting Syncfusion Support. 

We have prepared sample with asp.net core 2.2 but we are unable to reproduce the problem at our end. Refer to the sample Link:- 

We need some more additional details to find the cause of the issue. Share us the following details. 

  1. Complete Grid code example.
  2. Share screenshot/Video demo to replicate the issue.
  3. If possible replicate the issue in the above sample and revert us back.
  4. Share screenshot of script Error if any occurs.

Regards, 
Farveen sulthana T 



Abaid-ur-Rehman Zulfi
Replied On February 4, 2020 07:59 AM UTC

Hi,

The provided solution is for EJ1 whereas I am using EJ2 and again script is giving error. Following two directives are not available in EJ2

@using Syncfusion.JavaScript;
@using Syncfusion.JavaScript.Models;

and this line var gridObj = $("#FlatGrid").ejGrid("instance"); also generates run-time error.

I have researched & modified the code as below. However, in following code, line 1 & 2 works fine but run-time error is thrown on row.hide() citing 'hide' method is not available.
 var gridObj = document.getElementById('FlatGrid').ej2_instances[0]; // $("#Grid").ejGrid("instance");
        var row = gridObj.getSelectedRows();
        row.hide();



Dhivya Rajendran [Syncfusion]
Replied On February 5, 2020 09:59 AM UTC

Hi Abaid, 
  
Greetings from syncfusion support. 
  
Query #1:  Following two directives are not available in EJ2.@using Syncfusion.JavaScript;@using Syncfusion.JavaScript.Models; 
 
In EJ2 grid control there is no need of above directives instead that we should add below dependencies in the core application.
              1. Using Nuget Package Manager we need to add Syncfusion.EJ2.AspNet.Core package into your application.
 
              2. We need to install NewtonSoft.JSON as dependency since Syncfusion.EJ2.AspNet.Core dependent to NewtonSoft.JSON package. 
 
Refer the below link to create a ASP.NETCORE with Gird control. 
 
 
Query #2: I have researched & modified the code as below. However, in following code, line 1 & 2 works fine but run-time error is thrown on row.hide() citing 'hide' method is not available. 
 
We are happy to hear that you have found how to get the grid instances in EJ2. 
 
The hide() is a JQuery method, which is used to hide the selected element in the DOM. Since we have used pure javascript in EJ2 components. You can hide the element by adding class list e-hide for the selected row element to achieve your requirement. Please refer the below code example and sample for more information. 
  

 
  
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0]; 
            var selectedRows = grid.getSelectedRows(); 
            for (var i = 0; i < selectedRows.length; i++) { 
                      // syncfusion way 
                selectedRows[i].classList.add('e-hide'); 
                      // you can also hide selected row  element using html attributes 
               // selectedRows[i].hidden = true; 
               // selectedRows[i].style.display = 'none'; 
                
            }  
 
Please get back to us if you need further assistance. 
  
Regards,
R.Dhivya 


Abaid-ur-Rehman Zulfi
Replied On February 6, 2020 04:27 AM UTC

Thank you, it is working perfectly now.

Dhivya Rajendran [Syncfusion]
Replied On February 6, 2020 06:05 AM UTC

Hi Abaid, 

Thanks for your update. 

We are happy to hear that the provided solution was helpful to achieve your requirement. Please get back to us if you require further assistance from us. 

Regards, 
R.Dhivya  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon