Refresh Custom Grid

TodAnderson

Hi, 


I am looking for an easy way to refresh the contents of a custom grid.


 


I have created a grid that loads and fills on a form (when it opens), but the only way I can find to refresh the contents is to close and reopen the form. information is updated by other users, and I would like to have the form simply update when it detects a difference in the table...


 


any ideas welcome.


 


Tod


Anders Olsson

Hello Tod,


 


As far as I know there is no way to detect changes in table. But you can refresh the grid by running the query again: Grid.ExecuteQuery() for example when clicking a button.


Another way would be doing it periodically using a timer. That way you could detect changes by calculating checksums on the data.


 


Regards,


Anders

TodAnderson

Hi Anders,

 

This is what I have so far:

 



try{

Grid grid = Grid.CreateNew("myGRD");
grid.Width = 780; grid.Height = 500; grid.Top = 5; grid.Left = 5;


Form form = Form.CreateNewForm("myFRM", "myFRM" + customize.Utils.UniqueStringGenerator.Next());
form.Height = 600; form.Width = 800;
form.Value = "Sales Documents Today";

Button btn = Button.CreateNew("Close");
btn.SetSize(100, 18);
btn.Value = "CLOSE";
btn.SetPosition(form.Width - btn.Width - 10, grid.Top + grid.Height + 5);
form.AddItem(btn);

form.AddItem(grid);
form.Load();

string query = @"

SELECT T0.[DocNum], T0.[CardCode], T0.[CardName], T0.[DocDate], T0.[DocStatus]
FROM ORDR T0
WHERE convert(date, T0.[DocDate],103) = convert(date,GetDate(),103)";


grid.ExecuteQuery(query);

System.Timers.Timer timer = new System.Timers.Timer(10000);
System.Timers.ElapsedEventHandler Refresh = delegate{
try
{
grid.ExecuteQuery(query);
}
catch (Exception e){
StatusBar.WriteError(e.ToString());
}
finally{
timer.Enabled = true;
}};
timer.Elapsed += Refresh;
timer.Start();

btn.AddHandler_Click(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, new SwissAddonFramework.UI.EventHandling.ItemEvents.ClickEventHandler(delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.Click eventVal) {
eventVal.Form.Close();
timer.Stop() ;
}));

}
catch (Exception ex){
MessageBox.Show(ex.ToString(), "OK");
}


How would you suggest I make a checksum so that the flickering every second? and only refreshes when there is a difference.

 

Tod


Anders Olsson

Hi Tod,


 


Try CHECKSUM_AGG(CHECKSUM(*)) on your UDT in sql. If the value returned is different from the previous time data has changed.


 


Regards,


Anders

ChristianB

Hi,


 


I like to refresh a grid developed with UDT Handler but I dont seem to have the possibility for oGrid.RunQuery...


Error message is "RunQuery is not a member of SwissAddOnFramework.UI.Components.Grid"


 


Could you please advice how to refresch a UDT Handler Grid without open it again?


 


Best Regards


 


Christian


ChristianB

Hi,


 


... or it would also help to get the Query from a Grid so I can do it with "...ExecuteQuery" But I can't find a property in oGrid where the Query is stored


 


Kind Regards


 


Christian


0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post