Hi,
i want to ask about refresh content inside getCell i am trying to use refreshContent when edit EditText/toggleBuuton but not working
when trying it in checkBoxes working fine
Hi Mostafa,
Calling refreshContent() should not be necessary in order to update your EditText. If you set the text on your EditText from inside the Button click event then it should already have been updated in the UI. refreshContent() is not necessary for that. In all honesty refreshContent() shouldn't even be available and it won't exist in the final version of the grid (it's still a CTP control). If you need to update the UI without updating the data then you will need to get the cell and then get the control from within the cell and set the control directly. This will update it in the UI.
I have the same case I used custom view control that contains from editText and button.
I want when click on button the edittext will change value without update data source for grid but I want to use refreshContent() method to refresh Grid view
Hi ueldeep,
What are you expecting to happen when you call refreshContent()? I don't see a reason for why you are calling this method when you are already updating the underlying data source property when the text is changed. The TextChanged event is fired when you type some text into the EditText and you are using this to update the underlying data source which is fine. At this point though, the EditText value and the underlying property value are in sync so I don't see any reason why you need to call refreshContent(). Did you override refreshContent in your CustomPriceViewCell class? If so, what are you doing inside that method?
Any updates
Hi, Thanks for reply
the following checkbox code :
@Override protected IGGridViewCell getCell(final IGGridView gridView, final IGListAdapter adapter, final IGCellPath path) { CustomCheckboxCellView cell = null; String cellKey = null; if (className.equals(SavedOrderGrid.class.getSimpleName())) { cellKey = this.getKey() + ((SavedOrderModel) adapter.getDataSource().get(path.getRow())).getOrderBasketNumber(); } else if (className.equals(OrdersMonitorGrid.class.getSimpleName())) { cellKey = ((OrderMonitorModel) adapter.getDataSource().get(path.getRow())).orderNumber + "_" + this.getKey(); }else if (className.equals(LiquidationSymbolsGrid.class.getSimpleName())) { cellKey = ((SymbolLiquidateModel) adapter.getDataSource().get(path.getRow())).symbolId + "_" + this.getKey(); } cell = (CustomCheckboxCellView) gridView.dequeueCellById(cellKey); if (cell == null) { cell = new CustomCheckboxCellView(gridView.getContext(), cellKey); cell.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ((GridSelectionModel) adapter.getDataSource().get(path.getRow())).selected = isChecked; if (gridView.cellAtPath(path) != null) { gridView.cellAtPath(path).refreshContent(); } if (isChecked && !((CustomGrid) gridView).getSelectedItems().contains(adapter.getDataSource().get(path.getRow()))) ((CustomGrid) gridView).getSelectedItems().add(adapter.getDataSource().get(path.getRow())); else if (!isChecked) { if (((CustomGrid) gridView).isAllSelected()) { ((CustomGrid) gridView).getSelectedItems().remove(adapter.getDataSource().get(path.getRow())); } else { ((CustomGrid) gridView).getSelectedItems().remove(adapter.getDataSource().get(path.getRow())); } }
listener.onCheckBoxChanged(adapter.getDataSource().get(path.getRow()), path); } }); } if (adapter.resolveValue(path) != null) cell.setChecked((boolean) adapter.resolveValue(path)); cell.setViewBackgroundColor(path.getRow()); return cell; }
--------------------------------------------------------------------------
and the following for editText and Toggle Button:
@Override protected IGGridViewCell getCell(final IGGridView igGridView,final IGListAdapter igListAdapter, final IGCellPath igCellPath) { String cellKey = null;// this.igGridView=igGridView; if(classType.equals("LiquidationSymbolsGrid")){ cellKey = ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).marketId +"_"+((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).symbolId + "_" + this.getKey(); } CustomPriceViewCell cell = (CustomPriceViewCell) igGridView.dequeueCellById(cellKey); if (cell == null) { cell = new CustomPriceViewCell(igListAdapter.getContext(), cellKey, new OnCellActionListener() { @Override public void onTextChanged(int id, Editable s, int rowIndex) { if(!s.toString().equals("")){ ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).sellPrice=Double.parseDouble(s.toString()); }else{ ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).sellPrice=Double.parseDouble("0"); igGridView.updateData(); } if (igGridView.cellAtPath(igCellPath) != null) { igGridView.cellAtPath(igCellPath).refreshContent(); } } @Override public void onButtonClick(int id, View v,Object dataModel) { if(OnCellActionListener.ACTION_1==id){ ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).sellPrice=tradeController.getNextPrice(new BigDecimal(((SymbolLiquidateModel)dataModel).sellPrice), tickFormula, true).doubleValue();// Log.i("trace", sellPriceValue+" : current"); }else{ ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).sellPrice =tradeController.getNextPrice(new BigDecimal(((SymbolLiquidateModel)dataModel).sellPrice), tickFormula, false).doubleValue(); } Log.i("trace", ((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).sellPrice+" : price"); igGridView.cellAtPath(igCellPath).refreshContent(); igGridView.updateData(); } }); } if (igListAdapter.resolveValue(igCellPath) != null) { if(classType.equals("LiquidationSymbolsGrid")){ if(((SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow())).orderType.equals("50")){ cell.setEnable(false); }else{ if(((CustomGrid)igGridView).isAllSelected()){ cell.setLayoutEnable(false); }else{ cell.setEnable(true); cell.setLayoutEnable(true); } } symbolLiquidateModel=(SymbolLiquidateModel)igListAdapter.getDataSource().get(igCellPath.getRow()); tradeController=new TradeController(context, null); ArrayList<ParameterValue> bestMarketParameterValues=null; ParameterValue numberFormat=null; tickFormula =null; MarketModel marketModel=ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getRegisteredMarkets().get(symbolLiquidateModel.getMarketId());
if(symbolLiquidateModel.getOrderType().equals("50")){ if(marketModel!=null){ bestMarketParameterValues = LookupsManager.getInstance().getParameterValues(Integer.valueOf(marketModel.getID()), LookupsConstants.BEST_MARKET_PRICE); tickFormula = ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getRegisteredMarkets().get(marketModel.getID()).getTickValue(); numberFormat = LookupsManager.getInstance().getParameterModel(Integer.valueOf(marketModel.getID()), LookupsConstants.CHANNEL_DECIMAL_DISPLAY, Integer.valueOf(ControllerConstants.CHANNEL_ID)); }else{ int marketId=Integer.valueOf(ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getMarketModels()[0].getID()); marketModel=ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getUnregisteredMarkets().get(symbolLiquidateModel.getMarketId()); bestMarketParameterValues = LookupsManager.getInstance().getParameterValues(marketId, LookupsConstants.BEST_MARKET_PRICE); tickFormula = ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getRegisteredMarkets().get(String.valueOf(marketId)).getTickValue(); numberFormat = LookupsManager.getInstance().getParameterModel(marketId, LookupsConstants.CHANNEL_DECIMAL_DISPLAY, Integer.valueOf(ControllerConstants.CHANNEL_ID)); }// Log.w("trace", tickFormula + " :tcick"); ProductModel productModel=marketModel.getProductBySymbolId(symbolLiquidateModel.getSymbolId()); if(productModel==null){ productModel=marketModel.getDeletedProductBySymbol(symbolLiquidateModel.getSymbolId()); } SymbolPriceFeedModel symbolPriceFeedModel=productModel.getSymbolPriceFeedModel(); sellPriceValue=symbolPriceFeedModel.getMarketPrice(Integer.valueOf(bestMarketParameterValues.get(0).getValue2())); }else{ if(marketModel!=null){ numberFormat = LookupsManager.getInstance().getParameterModel(Integer.valueOf(marketModel.getID()), LookupsConstants.CHANNEL_DECIMAL_DISPLAY, Integer.valueOf(ControllerConstants.CHANNEL_ID)); tickFormula = ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getRegisteredMarkets().get(marketModel.getID()).getTickValue(); }else{ int marketId=Integer.valueOf(ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getMarketModels()[0].getID()); marketModel=ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getUnregisteredMarkets().get(symbolLiquidateModel.getMarketId()); numberFormat = LookupsManager.getInstance().getParameterModel(marketId, LookupsConstants.CHANNEL_DECIMAL_DISPLAY, Integer.valueOf(ControllerConstants.CHANNEL_ID)); tickFormula = ConfigurationManager.getInstance().getMarketStructureResponse().getMarketStructureModel().getRegisteredMarkets().get(String.valueOf(marketId)).getTickValue(); } sellPriceValue= symbolLiquidateModel.getSellPrice(); }// Log.i("trace", "sell::"+sellPriceValue); cell.setText(NumbersFunctions.formatPrice(Integer.valueOf(symbolLiquidateModel.marketId), sellPriceValue)); cell.setRowIndex(igCellPath.getRow()); cell.setInputFilter(numberFormat); } cell.setDataModel(igListAdapter.getDataSource().get(igCellPath.getRow())); cell.setViewBackgroundColor(igCellPath.getRow()); }
return cell;
}