Jump to content

How to use Xtemplate inside DBGrid


asapltda

Recommended Posts

  • 3 weeks later...

Good evening,

this is an example of what I want to do but using unigui for Desktop, .

I haven't found the example for desktop, Multiple rows in a DBGRID column originating in a single record

could you tell me how to do it thanks?

 

image.png.52c1c695c78102738dc1a9a55af1e09d.png

 

This is the code I use on TUnimDBListGrid,

function beforeInit(sender, config)
{
    config.loadingText='Cargando';
  config.grouped=false;
  config.selectedCls='';
  config.itemTpl='<table style="width:100%;white-space: nowrap;vertical-align:middle;">'+

  '<tr>' + 
    '<td style="color:#000:padding-right:4px;" colspan="2"><strong> {8}   </strong>  &nbsp &nbsp   {1}   </td>'+
  '</tr>' + 

  '<tr>' + 
    '<td style="color:Blue: font-size:15px:padding-top:4px; padding-left:5px;color:#535454;" colspan="2" >  Destino: {2} &nbsp &nbsp  {3}   </td>'+
  '</tr>' + 
  

  '<tr>' + 
    '<td style="color:#000: font-size:15px:padding-top:4px; padding-left:5px;color:#535454;" colspan="2" >  <strong>   Ubicac: {4}  &nbsp &nbsp  CDesubicar: {6}  </strong>   </td>' + 
   '</tr>' + 
  
  '<tr>' + 
    '<td style="color:#000: font-size:15px:padding-top:4px; padding-left:5px;color:#535454;" colspan="2" >    Casig: <strong> {9} </strong>  /CDesU:  <strong> {10} </strong>  / CCanc: <strong> {11} </strong> </td>'+
  '</tr>' + 

   '</table>'; 
}

 

Link to comment
Share on other sites

12 hours ago, asapltda said:

could you tell me how to do it thanks?

Hi, You can try to use html into SQL script. I use it on my Desktop.

like this (H1, H2, H3 are set in CSS file):

SELECT ('<H2>'+ Products."PrdName" + '</H2>' 
        + '<ul>' + Groups."gName" + '</ul>'
        +  CASE 
            WHEN CONVERT (varchar (250)
                , STUFF (
                        (SELECT CHAR (10) + '|||' + REPLACE ([PName],'-','') + CHAR (10) + [PValue]
                        FROM OtherTable1
                        WHERE OtherTable1."ID" = Products."ID"
                FOR XML Path ('')),1,1,'')) <> ''
            THEN '<h3>' 
                + REPLACE (CONVERT (varchar (250)
                , STUFF (    (SELECT  CHAR (10) + '|||' + REPLACE ([PName],'-','') + CHAR (10) + [PValue] 
                        FROM OtherTable1
                        WHERE OtherTable1."ID" = 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."V") + '</h3></ul></ul>'
.............

    ) as Opisanie

FROM TableName

WHERE ....

css file:

html,body,h1,h2,h3,h4,h5,h6 {
  font-family: "Segoe Script", cursive, sans-serif;
  line-height: 1.2;
}

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...