Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Can this be done for randomized rows in a grid?

So now I have a grid with 13 rows that need to be randomized and then shown 1 row at a time.

Is that even possible?

asked Mar 21, 2017 by jas8278 Bronze (750 points)

1 Answer

0 votes
This code worked for me when I enabled randomized rows in my grid settings:

    var rowsList = $('input[name=hid_row_list_[% QuestionName() %]]').val().split(',').map(Number);
    for (var i = 1; i < rowsList.length; i++) {
        var row = rowsList[i];
        $('#[% QuestionName() %]_r' + row + '_row').hide();
        $('.mobile_grid_question.[% QuestionName() %]_r' + row).closest('.mobile_grid_card').hide();

function updateS6Rows() {
    var rowsList = $('input[name=hid_row_list_[% QuestionName() %]]').val().split(',').map(Number);
    var interval = setInterval(function(){
        for (var i = 0; i < rowsList.length - 1; i++) {
            var row = rowsList[i];
            var nextRow = rowsList[i + 1];
            if (SSI_GetValue('[% QuestionName() %]_r' + row) > 1) {
                $('#[% QuestionName() %]_r' + nextRow + '_row').show();
                $('.mobile_grid_question.[% QuestionName() %]_r' + nextRow).closest('.mobile_grid_card').show();
    }, 50);
answered Mar 22, 2017 by Zachary Platinum Sawtooth Software, Inc. (147,200 points)
I'm going to check it in a couple of different browsers then.  Firefox was what I tested in and all the rows did come up - but not one after the other. They popped up in numerical position.
no luck - - rows show up in random order but in numerical order
The rows are showing up in order even with the new code?  Are you randomizing using a constructed list or with the grid's randomization setting?
Sorry Zach . . . at the end of a 16 hour day.  The code is working. I had to change (SSI_GetValue('[% QuestionName() %]_r' + row) > 1) to > 0 . . but all is well now!

Thank you so much for all you do!