How to select a row in DataTable based on column value

2,017 views
Skip to first unread message

Anuj Chauhan

unread,
Apr 2, 2014, 1:56:49 AM4/2/14
to ang...@googlegroups.com
Hi Team,

I am fairly new to angular js world and badly struggling with one issue.

I have used angularized DataTable. This table have 6 columns, the name of first column is "Book ID"
Now, I need to programatically  select the row in that table where "Book ID" is equal to a given value. 

It seems to be a generic requirement and I guess there should be a way available to do it.

Request you to kindly help me to solve this problem.

Regards,
Anuj

Sander Elias

unread,
Apr 2, 2014, 2:31:37 AM4/2/14
to ang...@googlegroups.com
Hi Anuj,

What do you mean with 'select a row'?
You want to visually mark the row? you want a checkbox to be checked? you want to move the row to a different position?
Here is a sample, that might help. 
If you need something different, build a plunker that makes it possible to help you.

With kind regards
Sander
 

Anuj Chauhan

unread,
Apr 2, 2014, 3:20:04 AM4/2/14
to ang...@googlegroups.com
Hi Sander,

Thank you for taking time to answer it.

By saying select it could be simply finding that row, lets say call the "Click()" event of that row, if any.

I have updated the plunk and you can see it at this location http://plnkr.co/edit/81hmFle0oNOweXEyN7OC?p=preview
I have added Select "seller...@comtrail.com"  link, On click of this newly added link I want to select row from above grid which has email id as "seller...@comtrail.com"

Please have a look, and help me to solve this problem.

Regards,
Anuj

Sander Elias

unread,
Apr 2, 2014, 3:47:43 AM4/2/14
to ang...@googlegroups.com
Hi Anuj,

Thank you for taking time to answer it.
You are welcome.
 
By saying select it could be simply finding that row, lets say call the "Click()" event of that row, if any.
Hmm, that's not the 'Angular way'.  In angular, your data is central, and the DOM will follow your data. You don't traverse the DOM, and then emit an event on a found element.
You don't need to do that, as you already have the data in your scope.
I adapted the sample, so you can see what I mean: http://plnkr.co/edit/pHjwGQfXq2U91B8MszcB?p=preview

Don't hesitate to ask if you have more questions.

Regards
Sander

Richard Seldon

unread,
Apr 2, 2014, 4:19:40 AM4/2/14
to ang...@googlegroups.com
Hello,

Looking for some recommendations. Have used JQuery Datatables heavily in the past, and it is a great plugin.
It has become the front-runner / defacto plugin to use when handling rich data tables in JQuery world.


Please can anyone offer best alternatives (ready to configure and use plugin) in Angular world?  

Require filtering, sorting, row selection, ajax data lookups, default styling would be nice to have.

There is this - http://ngmodules.org/modules/ng-table  - I briefly contacted the author - he was caught up in the war in Ukraine the last time we spoke.

Please, any suggestions would be welcome. 

Or does the community generally just hand-code all their own tables as Angular is expressive and easy enough to work with to do this?

Thank you.


Sander Elias

unread,
Apr 2, 2014, 6:55:18 AM4/2/14
to ang...@googlegroups.com
Hi Richard,

I do like the way ng-table is set up. For my own stuff I hand-code my tables, indeed because it is simple enough. Earlier in this thread I posted my 
seSuperTable sample. In there there are some directives that might help you get the idea on how to automate stuff you do frequently.
HTML is very well suited for laying out tables. Angular is very well suited to put in the missing pieces!

Regards
Sander

Richard Seldon

unread,
Apr 2, 2014, 9:06:28 AM4/2/14
to ang...@googlegroups.com
Hi Sander,

Thank you for your reply. Very helpful.

Not sure which thread you were referring to below, but googled for seSuperTable with your name and found this plunker:



That looks really nice, and relatively lightweight! Think that would work with current requirements - only remaining concern is support for pagination.
I realise this can be done in Angular but just hoping to get this for free ;)

Do you have any version of seSuperTable that provides this? 

Else, I shall try to understand what would be required and implement that myself. Guess the data for pagination could be either all stored client side, or looked up on page request.

Best regards,


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Apr 2, 2014, 9:43:03 AM4/2/14
to ang...@googlegroups.com
Hi Richard,

Pagination isn't that hard. And it can be an extra directive for the se-supertable set. It wasn't too long ago I was helping somebody else with pagination in this group too. 
I believe there was a nice and fast solution for pagination in that. If I recall correctly it is easily adaptable to my seSupertable.
If you have difficulties with it, just ask, and I will take a look at it.

Regards
Sander


Richard Seldon

unread,
Apr 2, 2014, 9:50:18 AM4/2/14
to ang...@googlegroups.com
Thanks Sander, appreciate the help.

Cheers,


Sander Elias

unread,
Apr 2, 2014, 9:54:21 AM4/2/14
to ang...@googlegroups.com
Hi Richard,

I found the thread I was refering too, I didn't do too much in here, I just helped the guy to get his filters working up to speed.
here is the final fiddle of that thread (I just brushed it up a little bit, so the startFrom filter gives back a smaller set, so the paging works
faster!)

Richard Seldon

unread,
Apr 14, 2014, 8:58:44 AM4/14/14
to ang...@googlegroups.com

This appears to be exactly what I had in mind:

Reply all
Reply to author
Forward
0 new messages