erich.wanker Posted September 10, 2013 Posted September 10, 2013 Hello, is it possible to make a wordwrap in uniDBGrid ? I think, something like dynamical heigh of a row .. depending on the content of a cell ... i have 2 fields .. the first field is a Integer to identivie the right Image ... the image is drawn per: procedure TUniMainModule.ZQuery3ID_PERSONGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin ... DisplayText:=true; text:=sender.AsString; .... text:='<img width=16 height=16 src="'+uniservermodule.FilesFolderURL+'/'+image+'"/>'; end; the second field is a String with different lenght .. AND the Grid is very small .. so i prefere a dynamic wordwrap of every row Thanks for help Quote
heromo80 Posted September 10, 2013 Posted September 10, 2013 I usually use calculated fields... procedure TUniMainModule.dtFamiliaCalcFields(DataSet: TDataSet); begin dtFamilianombre.AsString := '<p class="x-p-infofam">' + dtFamiliafamilia.AsString + '</p>'; end; and css... .x-p-infofam { word-wrap: break-word; white-space: pre-line; padding: 2 5 2 5;} 1 Quote
erich.wanker Posted September 11, 2013 Author Posted September 11, 2013 ..works perfect :-) Thank you Quote
likemike Posted May 1, 2021 Posted May 1, 2021 Hello! I've tried this code, but without success. In my case the grid shows nothing in the string column (I use the mobile grid version TUnimDBGrid). I've set "AllowHTML" to true. What do I wrong? Regards Mike Quote
irigsoft Posted May 1, 2021 Posted May 1, 2021 2 hours ago, likemike said: Hello! I've tried this code, but without success. In my case the grid shows nothing in the string column (I use the mobile grid version TUnimDBGrid). I've set "AllowHTML" to true. What do I wrong? Regards Mike Hello, try something else: 1. uniDBGrid is render html in column data 2. if you make sql select with adding html then you will get what you want. like this: Add ('Select Name from Mytable '), replace with this : Add ('Select ''<H1>'' + Name + ''</H1>'' from Mytable) If You want to wordwrap, then just use: Add ('Select Replace (Name,'' '',''</br>'') as wwName from Mytable '); Quote
likemike Posted May 1, 2021 Posted May 1, 2021 Thank you for your answer, but this will not work for me, because I want to wrap a long string with a lot of words. It should be wrapped, when the string reaches the end of the column. This CSS operator should do this word-wrap: break-word; but it won't work. Quote
irigsoft Posted May 1, 2021 Posted May 1, 2021 1 hour ago, likemike said: Thank you for your answer, but this will not work for me, because I want to wrap a long string with a lot of words. It should be wrapped, when the string reaches the end of the column. This CSS operator should do this word-wrap: break-word; but it won't work. Did You try like this: word-wrap: break-word !important; Quote
likemike Posted May 1, 2021 Posted May 1, 2021 The problem is, that with this css and the OnCalcFields the column is shown completly empty. Quote
irigsoft Posted May 1, 2021 Posted May 1, 2021 Please, try to insert css in SQl script, if that can help Quote
irigsoft Posted May 1, 2021 Posted May 1, 2021 I use this in my mssql script to manipulate text in column: SELECT ('<H2 style="color:blue;text-align:center;">'+ Products."Name" + '</H2>' + CASE WHEN CONVERT (varchar (250) , STUFF ( (SELECT CHAR (10) + '|||' + REPLACE (ParamName,'-','') + CHAR (10) + ParamValue FROM OderDataArt WHERE OderDataArt."ID_Art"=Products."ID" FOR XML Path ('')),1,1,'')) <> '' THEN '<h3>' + REPLACE (CONVERT (varchar (250) , STUFF ( (SELECT CHAR (10) + '|||' + REPLACE (ParamName,'-','') + CHAR (10) + ParamValue FROM OderDataArt WHERE OderDataArt."ID_Art"=Products."ID" FOR XML Path ('')),1,1,'')) ,'|||','</br>') + '</h3>' ELSE '' END + '<ul><ul><h3 align="right">Price: ' + CAST (ROUND (Products."Price",2) as varchar (20)) + ', ' + lower (Products."Val") + '</h3></ul></ul>' '...... Maybe You can insert standart css format in column data Quote
irigsoft Posted May 1, 2021 Posted May 1, 2021 10 minutes ago, likemike said: OK! I've done it. Thanks! did You succeed ? Quote
likemike Posted May 1, 2021 Posted May 1, 2021 The error was made by me. Maybe it helps to prevent this for other users: When you add a new calculated string field in a firebird database the length is set to 20 characters by default. Of course this wasn't enough to save my string + the html commands. So the solution is to set the length to 200 or more characters. And it's necessary to set the CSS to "important" (otherwise it won't work): word-wrap: break-word !important; 1 Quote
irigsoft Posted May 2, 2021 Posted May 2, 2021 9 hours ago, likemike said: Of course this wasn't enough to save my string + the html commands. So the solution is to set the length to 200 or more characters. just for information: In my example i use html manipulation in SQL query and not needed extend in database field. Quote
likemike Posted May 2, 2021 Posted May 2, 2021 1 hour ago, irigsoft said: just for information: In my example i use html manipulation in SQL query and not needed extend in database field. Yes I know, but firebird SQL isn't that powerful. There are not enough commands available to do what I want in SQL. Quote
Sherzod Posted May 2, 2021 Posted May 2, 2021 49 minutes ago, likemike said: but firebird SQL isn't that powerful. There are not enough commands available to do what I want in SQL. Hello, If I understand you correctly, then you can also use stored procedures. Quote
likemike Posted May 2, 2021 Posted May 2, 2021 1 hour ago, Sherzod said: Hello, If I understand you correctly, then you can also use stored procedures. This in another option, but the solution with calculated fields fit the best for me, because the database is used in common with other applications. So it's better not to change anything in the stored procedures of the database. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.