bruno-pere
-
Posts
95 -
Joined
-
Last visited
-
Days Won
5
Content Type
Profiles
Forums
Events
Posts posted by bruno-pere
-
-
MSSQL + ADO.
Long updates and operations in Stored Procedures.
No problems.
Bye!
Bruno
- 1
-
Thx! Sometimes we forget to use the easy way! I was trying with ajax.
It worked now, but required a change.
The grid immediately posts the changes or abort the operation based on a column value.
In Grid.ExtEvents->ValidateEdit
function OnValidateedit(e)
{
ajaxRequest(UniFrameTransf.GridTransf,
'ValidateEdit',
['val='+e.value]);
}
In the Grid.OnAjaxEvent
procedure TUniFrameTransf.GridTransfAjaxEvent(Sender: TComponent; EventName: string;
Params: TStrings);
begin
if EventName='ValidateEdit' then
begin
AbortEdit := AdoQueryTransf.FieldByName('OPERACAO').AsString='R';
if not AbortEdit then
begin
if not (AdoQueryTransf.State in ([dsEdit, dsInsert])) then
AdoQueryTransf.Edit;
AdoQueryTransfQUANTIDADE.Value := Params.Values['val'];
AdoQueryTransf.Post;
end;
end
end;
In TADOQuery.OnBeforeEdit
procedure TUniFrameTransf.ADOQueryTransfBeforeEdit(DataSet: TDataSet);
begin
if AbortEdit then
Abort;
end;
Declare AbortEdit as boolean in private.
Thx!
Bruno
-
Hi!
I want to enable/disable row editing in a grid based on a value of a cell (linked to a dataset).
I tried beforeedit event but without success.
Thx!
Bruno
-
Worked here... but i appreciate a better solution...
In the Grid ExtEvents -> OnValidateEdit
function OnValidateedit(e)
{
ajaxRequest(UniFrameCons.GridCons,
'ValidateEdit',
['val='+e.value]);
}
In the Grid OnAjaxEvent
procedure TUniFrameCons.GridConsAjaxEvent(Sender: TComponent; EventName: string;
Params: TStrings);
begin
if EventName='ValidateEdit' then
begin
if not (AdoQueryCons.State in ([dsEdit, dsInsert])) then
AdoQueryCons.Edit;
AdoQueryConsQUANTIDADE.Value := Params.Values['val'];
AdoQueryCons.Post;
end;
end;
ATTENTION: This code works for me because ONLY one column can be edited in this grid. If you have more columns to be edited you should change this code.
Bye!
Bruno
-
Hi!
I am trying to post the grid record immediately to the database after a cell has been edited.
Actually, the record is posted to the database only after a scroll.
I've been playing with ExtEvents of the grid like OnAfterEdit, OnValidateEdit and some procedures of the ExtJs store like commitChanges() and save() but without success.
Does anyone know how to do that?
Thx!
Bruno
-
Thanks!!
A lot of samples already in production.
No more doubt that Unigui is exactly what I was looking for.
Web with no pain.
-
Nice one!
Thx!
Bruno
-
Thx Tugrul!
Nice!
As ISAPI?
Bruno
- 1
-
Thank you very much!
-
LOL
But, can you tell more details??
- How many clients are using (total and concurrent)
- Uptime (does it need constant restarts?)
- What kind of project
- Isapi, Standalone or service
- what database are you using and component for connection (ado, dbexpress)
thank you!
Bruno
-
Hi!
Is anyone using unigui in production? Comments please.
Thx!
Bruno
-
Hi!
After I recompiled as Standalone and installed the application in other server in my LOCAL network, I'm experiencing a lot of "Invalid session or session Timeout" messages. ONLY in IE 9. Firefox and Chrome is running ok.
Do you have any idea what's the cause?
What can I do do discover where is the problem?
Thx!
Bruno
-
The code was not working in Firefox and Chrome.
I did some changes and now it's working that browsers too.
In the Form.Script:
function zPrint(oTgt){
oTgt.focus();
oTgt.print();
}
function printIframe(id)
{
var iframe = id;
var ifWin = iframe.contentWindow || iframe; // the change
zPrint(ifWin);
return false;
}
In the button.ExtEvents.OnClick:
function OnClick(sender, e)
{
var frm = UniFormShowLink.UniURL1.iframe;
if (frm) {
printIframe(frm);
}
}
Bye!
Bruno
-
Working now.
zPrint function in the Form.Script.
And this in the extevents of the button:
function OnClick(sender, e)
{
var frm = document.getElementById("iframe_UniURL1_O20");
if (frm) {
zPrint(frm.contentWindow);
}
}
Why is the "_O20" added to the end of the iframe id?
Will this change after some page reloadings?
Bye!
Bruno
-
Does not work for me.
Can someone send a sample code?
UniGUI is creating my iframe with name iframe_UniURL_020. Is it correct?
I saw that in the HTML code.
Thx!
Bruno
-
The product is already a good product.
For now I think you should focus on really important things:
- roadmap;
- bug fixing;
- performance and stability;
- security;
And after that you can do other things like improve DBGrid.
Don't do another report solution. Microsoft Sql Reporting Services is a wonderful tool, FastReport is a wonderful tool and reportbuilder too.
Bruno
-
when I do that, it shows an error:
getCurrentMapType has no properties
thx!
Bruno
-
Farshad, i'm trying to add markermanager.js directly from the folder instead from the internet. But when I add /files/markermanager.js in the customfiles, i get some errors.
From the internet, it works.
What is the correct way to add custom javascript files locally?
Thx!
Bruno
-
What Farshad said is correct.
I did another application based on that demo and I use markermanager.js (http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markermanager/src/markermanager.js) to manage the markers.
1) Add the link to CustomFiles in ServerManager.
2) In the html frame->extevents->onafterupdatehtml something like this (added mgr = ...)
function Onafterupdatehtml(sender)
{
var latlng = new google.maps.LatLng(0,0);
var myOptions = {
zoom: 4,
minZoom: 4,
maxZoom: 20,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("uni_map_canvas"), myOptions);
googleMap = map;
/*google.maps.event.addListener(map, 'zoom_changed',
function() {
MainForm.UniTrackBar1.setValue(this.getZoom());
});*/
mgr = new MarkerManager(googleMap);
google.maps.event.addListener(mgr, 'loaded',
function(e) {
ajaxRequest(UniFrame1.UniHF,
'loaded',
[]);
});
google.maps.event.addListener(map, 'click',
function(e) {
ajaxRequest(UniFrame1.UniHF,
'mapClick',
['lat='+e.latLng.lat(), 'lng='+e.latLng.lng()]);
});
}
3) Add marks like this:
procedure TUniFrame1.CreateMapMarks;
var
path,c1,c2,lat,lng,info: string;
cmd1,cmd2: TStringList;
i: integer;
begin
if WebMode then
begin
try
path := AppPath + 'files\';
cmd1 := TStringList.Create;
cmd1.LoadFromFile( path + 'CreateMapMarks1.js' );
cmd1.Add('');
c1 := cmd1.Text;
cmd2 := TStringList.Create;
cmd2.LoadFromFile( path + 'CreateMapMarks2.js' );
cmd2.Add('');
c2 := cmd2.Text;
with UniMainModule do
begin
i := 0;
ADOTabPoste.First;
while not ADOTabPoste.Eof do
begin
inc(i);
lat := ADOTabPosteLatitude.Value;
lng := ADOTabPosteLongitude.Value;
info := ADOTabPosteIdentificador.Value;
c1 := c1 +
Format( c2,[
lat,
lng,
'false',
info,
IntToStr(i),
lat,
lng
]
);
ADOTabPoste.Next;
end;
ADOTabPoste.First;
end;
c1 := 'if (typeof googleMap=="object") {'
+ c1 +
'mgr.refresh(); };';
UniSession.AddJS(
c1
);
finally
cmd1.Free;
cmd2.Free;
end;
end;
end;
where the two external javascript files are:
createmapmark1.js
// Origins, anchor positions and coordinates of the marker
// increase in the X direction to the right and in
// the Y direction down.
var image = new google.maps.MarkerImage('imagens/light2.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(26, 32),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32));
var shadow = new google.maps.MarkerImage('imagens/light2.png',
// The shadow image is larger in the horizontal dimension
// while the position and offset are the same as for the main image.
new google.maps.Size(26, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
// Shapes define the clickable region of the icon.
// The type defines an HTML <area> element 'poly' which
// traces out a polygon as a series of X,Y points. The final
// coordinate closes the poly by connecting to the first
// coordinate.
var shape = {
coord: [1, 1, 1, 32, 26, 32, 26 , 1],
type: 'poly'
};
createmapmark2.js
var myLatLng = new google.maps.LatLng(%s, %s);
var marker = new google.maps.Marker({
position: myLatLng,
//map: googleMap,
shadow: shadow,
icon: image,
shape: shape,
draggable: %s,
title: '%s',
zIndex: %s
});
google.maps.event.addListener( marker, 'click', function(e){googleMap.setCenter(new google.maps.LatLng(%s, %s)); googleMap.setZoom( ((googleMap.getZoom()==20)?20:googleMap.getZoom()+2) );
ajaxRequest(UniFrameCadPostes.UniHF,
'mapClick',
['lat='+e.latLng.lat(), 'lng='+e.latLng.lng()]); } );
mgr.addMarker(marker,4);
4) And you can call some google functions like this:
procedure TUniFrameCadPostes.ClearMarkers;
begin
if WebMode then
UniSession.AddJS('if (typeof googleMap=="object") { mgr.clearMarkers(); mgr.refresh(); };');
end;
Did help?
Bye!
Bruno
-
Hi Farshad!
Can you tell at least approximate dates/plans?
Thx!
Bruno
-
Hi!
I think this is an incredible product! Delphi is very productive and I've never found anything similar for the web. UniGUI is the product I always searched for. But right now it's risky to create a comercial application based on it.
Is there any roadmap available?
When do you plan to release the first non-beta version?
Thank you!
Bruno
Dataset To HTML - Report
in Components and Code Samples
Posted
Not a component for UniGUI, but a good component to use in UniGUI.
My current web application needs basic reporting features, so I use this instead of other reporting solutions. So, if anyone needs to export or print a dataset using basic commands, this can help.
This component exports any linked dataset to HTML, in disk, then you can show a UniHTMLFrame of it and print. Working here for IE, Chrome and Firefox.
The component is attached.
Bye!
Bruno Lovatti
Use like this:
procedure TUniFrameInv.CreateHTML(fname: string);
begin
ToHTML.HTML.Clear;
ToHTML.PageOptions.Title := 'Produtos';
ToHTML.PageOptions.Header := 'Produtos da Extrafruti para Inventário <br>' +
'<br> LOJA: ' + TrimRight(UniCBoxLoja.Text) +
'<br> DATA: ' + FormatDateTime('dd/MMM/yyyy - hh:mm:ss',now) +
'<br> ENCARREGADO: ' + UniMainModule.UsuarioLogado;
if FileExists(fname) then
try
SysUtils.DeleteFile(fname);
except
//
end;
//ToHTML.PageOptions.Footer := FormatDateTime('dd/MMM/yyyy - hh:mm:ss',now);
ToHTML.FileName := fname;
// script - test
(*ToHTML.Script.Add('<script type="text/javascript">');
ToHTML.Script.Add('$(function(){');
ToHTML.Script.Add(' printPage();');
ToHTML.Script.Add('});');
ToHTML.Script.Add(' function printPage() {');
ToHTML.Script.Add(' focus(); print(); }');
ToHTML.Script.Add('</script>');*)
// accents for brazilian portuguese
ToHTML.Meta.Clear;
ToHTML.Meta.Add('<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />');
ToHTML.Meta.Add('<meta http-equiv="cache-control" content="no-cache" />');
ToHTML.Meta.Add('<meta http-equiv="pragma" content="no-cache" />');
ToHTML.CreateHTML;
//ToHTML.SaveHTML;
end;
Example of call:
fname := AppPath + 'impressao\PROD_' +
FormatDateTime('dd.mm.yyyy_hh.mm.ss',now)+'_'+
TrimRight(UniCBoxLoja.Text)+'.html';
CreateHTML(fname);
And the events like this:
procedure TUniFrameInv.ToHTMLAcceptColumn(Field: TField;
var Accept: Boolean);
var
fn: string;
begin
fn := Field.FieldName;
Accept := (fn='COD_PROD_SPALLA') or (fn='COD_PROD_EXT')
or (fn='NOME') or (fn='UNIDADE')
or (fn='QUANTIDADE') or (fn='QUANTIDADE_DEV')
or (fn='DES_GRUPO') or (fn='DES_SUBGRUPO');
end;
procedure TUniFrameInv.ToHTMLAcceptRow(Dataset: TDataSet;
var Accept: Boolean);
begin
Accept := true;
end;
procedure TUniFrameInv.ToHTMLGetColumnWidth(Field: TField;
var ColumnWidth: Integer; var ColumnTitle: string);
begin
if Field.FieldName='COD_PROD_SPALLA' then
begin
ColumnWidth := 50;
ColumnTitle := 'Cód. Spalla';
end
else
if Field.FieldName='COD_PROD_EXT' then
begin
ColumnWidth := 50;
ColumnTitle := 'Cód. na Loja';
end
else if Field.FieldName='NOME' then
begin
ColumnWidth := 350;
ColumnTitle := 'Nome';
end
else if Field.FieldName='UNIDADE' then
begin
ColumnWidth := 10;
ColumnTitle := 'Unid.';
end
else if Field.FieldName='QUANTIDADE' then
begin
ColumnWidth := 150;
ColumnTitle := 'Estoque';
end
else if Field.FieldName='QUANTIDADE_DEV' then
begin
ColumnWidth := 150;
ColumnTitle := 'Devolução';
end
else if (Field.FieldName='DES_GRUPO') then
begin
ColumnWidth := 60;
ColumnTitle := 'Grupo';
end
else if (Field.FieldName='DES_SUBGRUPO') then
begin
ColumnWidth := 80;
ColumnTitle := 'Subgrupo';
end;
end;
procedure TUniFrameInv.ToHTMLGetFieldValue(Field: TField;
var FieldValue: string);
begin
if (Field.FieldName='QUANTIDADE') or (Field.FieldName='QUANTIDADE_DEV') then
FieldValue := FormatFloat('0.##',Field.AsFloat)
else
if (Field.FieldName='DES_GRUPO') or (Field.FieldName='DES_SUBGRUPO') then
FieldValue := copy(Field.AsString,1,13)
else
if (Field.FieldName='NOME') then
FieldValue := copy(Field.AsString,1,100);
end;
procedure TUniFrameInv.ToHTMLSummaryRow(Field: TField);
begin
if Field.FieldName = 'COD_PROD_SPALLA' then
Inc(Count);
end;
procedure TUniFrameInv.ToHTMLSummaryStart;
begin
Count := 0;
end;
procedure TUniFrameInv.ToHTMLSummaryText(Field: TField;
var SummaryText: string);
begin
if Field.FieldName = 'COD_PROD_SPALLA' then
SummaryText := IntToStr( Count );
end;
To open in HTMLFrame (Form ShowLink attached):
procedure TUniFrameInv.OpenHTML(fname: string);
var
url: string;
begin
url := 'http://' + UniSession.Host + '/impressao/' +
ExtractFileName( fname );
UniFormShowLink.UniURL1.HTML.Assign(ToHTML.HTML);
UniFormShowLink.ShowModal;
end;
In the print button ExtEvents of Form ShowLink:
function OnClick(sender, e)
{
var frm = UniFormShowLink.UniURL1.iframe;
if (frm) {
//zPrint(frm.contentWindow);
printIframe(frm);
}
}
DatasetToHTML.zip
UnitShowLink.zip