Skip to main content
Known Participant
March 25, 2008
Question

setting input focus to cfgrid

  • March 25, 2008
  • 6 replies
  • 2830 views
I'm trying to figure out how to address an HTML-based cfgrid so that when the page loads, the grid gets the user input focus. Anyone know how you do this? The attribute selectOnLoad simply insures that a row is selected...but it doesn't actually put the user input focus on the grid.
    This topic has been closed for replies.

    6 replies

    Inspiring
    August 6, 2008
    onDocImagingSearchSelection is called by this function when I load and configure my grid after a new user's search.

    function loadGrid(booIndex) {
    ...
    g_objSearchGridSelectionModel.addListener('selectionchange',onDocImagingSearchSelection);
    ...
    Inspiring
    August 7, 2008
    You can also call the function as follows

    <cfajaxproxy bind="javascript:jsFunction({gridName.columnName})">

    This will act like an "event listnener" and fire the jsFunction every time the grid selection changes.


    Here is a tutorial on how to do this

    Ken
    Inspiring
    July 5, 2008
    Here was the final solution:

    // get the grid component
    var objSearchGrid = ColdFusion.Grid.getGridObject("searchGrid");

    // Create a reference to the selection model.
    g_objSearchGridSelectionModel = objSearchGrid.getSelectionModel();

    // get the datasource
    g_objSearchGridDataSource = objSearchGrid.getDataSource();

    ...

    // Get the selected row
    var objRow = g_objSearchGridSelectionModel.getSelected();
    var intRow = g_objSearchGridDataSource.indexOf(objRow);

    ...

    // Reset the grid focus back to the record changed
    g_objSearchGridSelectionModel.selectRow(intRow,true);
    August 6, 2008
    How do you call the below function in order to reflect the selected line in the CFGRID after the data is change from the form?

    // Reset the grid focus back to the record changed
    g_objSearchGridSelectionModel.selectRow(intRow,true);
    Inspiring
    July 4, 2008
    Thanks, but I had and did not see any good example. I did see the generic info:
    ColdFusion.Grid.getGridObject('yourgridname').getSelectionModel().selectRow(rownumber);

    However I still wasn't getting this part to work until I moved the call to the last action in the function where it was located, even though the other function effects did not deal directly with the grid.
    Inspiring
    July 1, 2008
    That did not seem to work for me. Also I was trying to something slightly different and was looking for a way to keep the grid selected on a record even after I did a grid refresh or reselect the record I was on after a grid refresh. For example, if a user edits a record in a form below the grid and saves the data, I don't want the selector moving to the first record, which it does now. I have the key field value for the record in the grid, just need to get the focus on it in the grid. Ideas?
    Inspiring
    July 3, 2008
    You will need to checkout the ext grid model to determine how this works, but

    You need to get the rowselectionmodel then use
    selectRow( Number row, [Boolean keepExisting] )


    Do a google search and you will find examples.

    Ken
    Inspiring
    March 29, 2008
    You need to reference the underlying ext grid


    This is untested code but should be close

    var myGrid = ColdFusion.Grid.getGridObject("gridName");
    selModel=myGrid.getSelectionModel();

    selModel.selectRow(Number row) ;

    Ken
    lchalnickAuthor
    Known Participant
    March 29, 2008
    Thank you. Will give it a shot.
    lchalnickAuthor
    Known Participant
    March 28, 2008
    Okay, so no clues here, eh?

    I believe that CF's HTML grid is essentially a set of DIVs, but there is apparently a keyboard interface that enables you to use the keyboard to select rows. So one would think that there is a way to select one of the divs when the page loads.