function sqGridSelect(grid, rowIndex, colIndex, row, params) {

    var value = "";
    if ("value" in params) {
        value = params["value"];
    }

    var options = "";
    if ("options" in params) {
        options = JSON.parse(params["options"]);
    }

    var isDisabled = false;
    if (row.disabled) {
        isDisabled = true;
    }
    if (grid.getCellCustomData(rowIndex, colIndex, "cellsDisabled")) {
        isDisabled = true;
    }

    var customValue = grid.getCellCustomData(rowIndex, colIndex, "cellsSelectValues")
    if (customValue != null) {
        value = customValue;
    } else {
        grid.setCellCustomData(rowIndex, colIndex, "cellsSelectValues", value)
    }

    var customOptions = grid.getCellCustomData(rowIndex, colIndex, "cellsSelectOptions")
    if (customOptions != null) {
        options = customOptions;
    }

    IncrementalDOM.elementOpenStart('div');
    IncrementalDOM.attr("class", "grid-widget-select");
    IncrementalDOM.elementOpenEnd('div');

    IncrementalDOM.elementOpenStart('select');
    IncrementalDOM.attr("value", value);
    if (isDisabled) {
        IncrementalDOM.attr("disabled", "disabled");
    }
    IncrementalDOM.attr("onchange", function(e) {
        e.stopPropagation();
        var newValue = e.target.value;
        grid.setCellCustomData(rowIndex, colIndex, "cellsSelectValues", newValue);
        sqGridSendEvent(e, "selectUpdated", newValue);
    });
    IncrementalDOM.attr("onmousedown", function(e) {
        e.stopPropagation();
    });
    IncrementalDOM.elementOpenEnd('select');

    for (var optionKey in options) {
        var optionValue = options[optionKey];
        IncrementalDOM.elementOpenStart('option');
        IncrementalDOM.attr("value", optionKey);
        if (optionKey == value) {
            IncrementalDOM.attr("selected", "selected");
        }
        IncrementalDOM.attr("value", optionKey);
        IncrementalDOM.elementOpenEnd('option');
        IncrementalDOM.text(optionValue);
        IncrementalDOM.elementClose('option');
    }

    IncrementalDOM.elementClose('select');
    IncrementalDOM.elementClose('div');
}

function sqGridSelectValueSet(grid, rowIndex, colIndex, newValue, disableBodyRedraw) {
    grid.setCellCustomData(rowIndex, colIndex, "cellsSelectValues", newValue);
    if (!disableBodyRedraw) {
        grid.bodyRedraw();
    }
}

function sqGridSelectOptionsSet(grid, rowIndex, colIndex, newValue) {
    grid.setCellCustomData(rowIndex, colIndex, "cellsSelectOptions", newValue);
    grid.bodyRedraw();
}

function sqGridSelectValueGet(grid, rowIndex, colIndex) {
    return grid.getCellWidgetValue(rowIndex, colIndex, "cellsSelectValues");
}