Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

selectedIndex and row count

Community Beginner ,
Sep 28, 2009 Sep 28, 2009

Hi, thanks for looking at my question.  Simple question probably.  How do I can I get index of the selected row in an html cfgrid.  I have a button which calls startEditing(...), but how do I get the index of the selected row?  Also, how do I get the row count?

Thanks for your help.

839
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2009 Sep 28, 2009
LATEST

Although it seems like there should be an easier way to do this, here's what I came up with.

  <cfinput type="button"
    name="btnEdit"
    value="Edit Line"
    onClick="editLine();" />


...


<script type="text/javascript">

  function getSelectedIndex(grid)
  {
    for (var i=0; i < grid.dataSource.data.items.length; i++)

      if (grid.getSelectionModel().isSelected(i))

        return i;
  }
     
  function editLine()
  {
    var grid = ColdFusion.Grid.getGridObject('gvExhibLines');
    grid.startEditing(getSelectedIndex(grid), 1);
  }

</script>

Still, if there is an easier or more elegant way of accomplishing the same, I would love some feedback.  I'm curious why there isn't a simple grid.selectedIndex.

Also, this line:

  grid.dataSource.data.items.length

returns 15 (which is my grids page size) regardless of how many rows there are in my grid.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources