Indigo Rose Software
  #1  
Old 2 Weeks Ago
Scriptonite's Avatar
Scriptonite Scriptonite is offline
Indigo Rose Customer
 
Join Date: Oct 2009
Location: 127.0.0.1
Posts: 41
Datagrid Issue

I hit a weird issue with the datagrid. I am saving the data to a MySQL database (with Ulrich's fantastic plugin). I am getting the grid data and saving it to the database with

Code:
sCurrentRows = Grid.GetRowCount("Grid1");
sCurrentRows = sCurrentRows-1;
local sSelTable = ComboBox.GetItemData("ComboBox1", ComboBox.GetSelected("ComboBox1"));
      
MySQL.Query("DROP TABLE  "..sSelTable);
MySQL.Query("DROP FROM settings WHERE ID = '"..sSelTable.."'");
      
MySQL.Query("CREATE TABLE "..sSelTable.."(title VARCHAR( 100 ) NOT NULL ,weight VARCHAR( 30 ) NOT NULL ,buy VARCHAR( 100 ) NOT NULL ,sell VARCHAR( 100 ) NOT NULL )");
      
                         for t=1,sCurrentRows do
                         
                         rowTitle=Grid.GetCellText("Grid1", t, 0)
                         rowWeight=Grid.GetCellText("Grid1", t, 1)
                         rowBuy=Grid.GetCellText("Grid1", t, 2)
                         rowSell=Grid.GetCellText("Grid1", t, 3)
                       
                          
MySQL.Query("INSERT INTO "..sSelTable.." VALUES('"..rowTitle.."','"..rowWeight.."','"..rowBuy.."','"..rowSell.."')");
                    
                         end
      
      LoadGrid();
      
Dialog.Message("Done", "Settings Saved", MB_OK)
My issue is if the last cell in the last row of the grid is selected the data won't save to the database. I have tried to change the focus, set the text, reload the grid and none of it has worked. Unless I manually select a different cell or add a new row the value will not save. What am I missing?
__________________
User error: replace user and press any key to continue.

Last edited by Scriptonite; 2 Weeks Ago at 10:41 PM.
Reply With Quote
  #2  
Old 2 Weeks Ago
Dermot Dermot is offline
Indigo Rose Customer
 
Join Date: Apr 2004
Location: Vancouver, Canada
Posts: 1,520
The grid row index is zero based but you are starting at 1. Perhaps that is the problem.
__________________
Dermot

AMS Add-ons - xDialog.com

A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.
Reply With Quote
  #3  
Old 2 Weeks Ago
Scriptonite's Avatar
Scriptonite Scriptonite is offline
Indigo Rose Customer
 
Join Date: Oct 2009
Location: 127.0.0.1
Posts: 41
I started it at 1 because 0 is a fixed row. I also just discovered the cell data won't save from anywhere on the grid if I don't click off of it before I try to save. It can be in the middle of a row or the end. It's like the grid wants a SetUpdateCell function. How can I tell the grid the cell is updated and the cell data should be set. I've tried the set text and refresh with no luck.
__________________
User error: replace user and press any key to continue.
Reply With Quote
  #4  
Old 2 Weeks Ago
Scriptonite's Avatar
Scriptonite Scriptonite is offline
Indigo Rose Customer
 
Join Date: Oct 2009
Location: 127.0.0.1
Posts: 41
Solved the issue. It seems that the grid needs to lose focus entirely to update the data. It started working correctly after I added the status dialog before the save function.
__________________
User error: replace user and press any key to continue.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software