This is a migrated thread and some comments may be shown as answers.

[Solved] Display/Hide lines?

7 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julien
Top achievements
Rank 1
Julien asked on 12 Dec 2011, 10:14 AM
Hi,

For a customer I need to have the possibility to hide some rows(like, the user select some rows, and click on the "Hide" button, it's not something which can be based on a filter, its only to help the customer.) He also want a button which "shows all" rows.

How can it be achieved with your library? It's not a big deal if it implies a reload of the page.

7 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 12 Dec 2011, 01:49 PM
Hello Julien,

If I understand you correctly, you simpply want to hide rows temporarily, without this affecting the datasource in any way. In this case you should use standard Javascript DOM operations to apply a display:none style (or jQuery hide() method) to the selected rows (e.g. the ones with a t-state-selected CSS class).

Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Julien
Top achievements
Rank 1
answered on 13 Dec 2011, 08:33 AM
Exactly.

But I don't know how to retrieve all selected/unselected rows?

I'm not aware of your t-state-selected
0
Dimo
Telerik team
answered on 13 Dec 2011, 11:11 AM
Hi Julien,

The selected rows of the MVC Grid have a t-state-selected CSS class applied to the corresponding <tr> elements. In case you are not aware how to find out all rows with that CSS class with jQuery and hide / show them, please get familiar with the jQuery API, because this knowledge is fundamental and required in order to work easily with our MVC extensions.

var grid = $("#GridID");
$("tr.t-state-selected", grid).hide();

$("tr.t-state-selected", grid).show();


http://demos.telerik.com/aspnet-mvc/grid/selectionclientside

Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Julien
Top achievements
Rank 1
answered on 13 Dec 2011, 11:16 AM
I've used jQuery before, but I've no idea of the "t-state-selected" class.

This makes me several questions:

-I was thinking that we can select only ONE row, but add combobox on several, is that true?
-Have you a reference somewhere of all this kind of css classes?
-Have you a css style for non-selected rows? Because I need to hide all rows which aren't selected.
0
Dimo
Telerik team
answered on 13 Dec 2011, 01:24 PM
Hello Julien,

1. Yes, you can select only one row, my mistake. I didn't understand the second part for the question. You can have any content in the Grid cells, e.g. by using templates.

2. I am afraid not. You can inspect the Grid HTML output with Firebug if you need specific information about an element.

3. No, but you can use the jQuery :not() selector to get all rows that don't have the t-state-selected CSS class.

Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Julien
Top achievements
Rank 1
answered on 13 Dec 2011, 03:31 PM
Okay, then, how can we get all rows which aren't in the "list of checked" item?
0
Marc
Top achievements
Rank 1
answered on 13 Dec 2011, 11:54 PM
You could associate the Checkboxes with an ID and select them with:

$(".MyCheckBoxClass :not(:selected)")
//OR
$(".MyCheckBoxClass :not(:checked)")

Although that will be more of something you perform logic on server side, as you'll likely have to retrieve the associated row data for each entry.
Tags
Grid
Asked by
Julien
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Julien
Top achievements
Rank 1
Marc
Top achievements
Rank 1
Share this question
or