diff --git a/visualpython/js/com/com_Kernel.js b/visualpython/js/com/com_Kernel.js index 3540d1f0..addb7093 100644 --- a/visualpython/js/com/com_Kernel.js +++ b/visualpython/js/com/com_Kernel.js @@ -610,10 +610,14 @@ define([ * @param {*} dataframe * @returns */ - getRowList(dataframe) { + getRowList(dataframe, start_idx) { var that = this; + if (typeof start_idx === 'undefined') { + start_idx = 0; + } + return new Promise(function(resolve, reject) { - that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}))', dataframe)) + that.execute(com_util.formatString('_vp_print(_vp_get_rows_list({0}, {1}))', dataframe, start_idx)) .then(function(resultObj) { resolve(resultObj); }).catch(function(err) { diff --git a/visualpython/js/m_apps/Subset.js b/visualpython/js/m_apps/Subset.js index 7c7c74c8..41af3ef4 100644 --- a/visualpython/js/m_apps/Subset.js +++ b/visualpython/js/m_apps/Subset.js @@ -343,10 +343,13 @@ define([ $(this.wrapSelector('.select-row .vp-ds-select-box.left')).on('scroll', function() { if ($(this).scrollTop() + $(this).innerHeight() >= ($(this)[0].scrollHeight - 2)) { let scrollPos = $(this).scrollTop(); + if (that.state.rowLimit > that.state.rowList.length){ + return; // Prevents scroll from being fixed downwards + } let start = that.state.rowLimit; let end = start + 10; let subsetVariable = com_util.formatString('{0}.iloc[{1}:{2}]', that.state.pandasObject, start, end); - vpKernel.getRowList(subsetVariable).then(function (resultObj) { + vpKernel.getRowList(subsetVariable, start).then(function (resultObj) { let { result } = resultObj; var { list:rowList } = JSON.parse(result); rowList = rowList.map(function (x) { @@ -361,9 +364,9 @@ define([ rowList = rowList.map(function (x) { return { ...x, - label: x.location + '', - value: x.location + '', - code: x.location + '', + label: x.label + '', + value: x.value + '', + code: x.code + '', }; }); } diff --git a/visualpython/python/pandasCommand.py b/visualpython/python/pandasCommand.py index aee1338d..4f8301c6 100644 --- a/visualpython/python/pandasCommand.py +++ b/visualpython/python/pandasCommand.py @@ -11,7 +11,7 @@ # from IPython.core.display is deprecated since IPython 7.14 from IPython.display import display -def _vp_get_rows_list(df): +def _vp_get_rows_list(df, start_idx=0): """ Get Rows List with Detail Information """ @@ -19,7 +19,8 @@ def _vp_get_rows_list(df): indexType = str(df.index.dtype) # make dict for rows info for i, r in enumerate(df.index): - rInfo = { 'label': r, 'value': r, 'location': i } + rInfo = { 'label': r, 'value': r, 'location': start_idx + i } + # value if type(r).__name__ == 'str': rInfo['value'] = "'{}'".format(r)