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

Selecting a kendoGrid row now working in a Jasmine test

4 Answers 485 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 Nov 2011, 05:21 PM
I'm using Jasmine for BDD style testing.  I'm testing that selecting a row in a kendoGrid will call my callback function.  To test this I'm creating an element on the fly using
element = $('<div></div>'); 

when I attach a kendo grid to a div under that dynamically created div, it mostly seems to work except for selection.  I can populate the grid with data and see the correctly generated html in the debugger.  However, if I do :
 var firstRow = kendoGrid.tbody.find(">tr:first");
kendoGrid.select(firstRow);

Then my workspaceGrid.Select callback is not called, and the grid.select() returns no elements.
Is there a better way to host the grid when I'm doing unit testing?
I find the syntax for selecting a particular row very awkward. I would be much easier to do
kendoGrid.select(0) to get the first row.


4 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 22 Nov 2011, 09:26 PM
I found the source of the problem, but I'm not sure how to fix it.  In the kendo.grid.js file:

ROW_SELECTOR = "tbody>tr:not(.k-grouping-row):visible", 

The :visible selector is causing the row to not select since it's not visible. The entire div it's inside of
only exists as an independent DOM node, so it's not visible. Why restrict the row selection to visible rows?
How can I select row 20 from a list that only displays 10 rows at a time for example?
0
Nikolay Rusev
Telerik team
answered on 25 Nov 2011, 09:06 AM
Hello David,

Is this the scenario that you have? http://jsfiddle.net/VctR5/12/

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Daniel
Top achievements
Rank 1
answered on 13 Jan 2012, 07:56 AM
 Hai Nikolay,
               I want to get a  data from the  selected row of grid, what method i should use to get  data of a selected row
0
Nikolay Rusev
Telerik team
answered on 13 Jan 2012, 09:13 AM
Hi,

The following demo shows how to get notified when selection change:
http://demos.kendoui.com/web/grid/events.html

Once you get the selected item you can extract any data from it.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or