SQL - Add a border bottom when column value changes

喜你入骨 提交于 2019-12-25 04:43:06

问题


I'm trying to add a border bottom red style to a table when the column value changes.

As shown in the picture, I want to add a bottom border when FamilyID changes it's value.

Any help is greatly appreciated and thank you in advance!


回答1:


I have implemented same thing on classic report of employee , you can check url https://apex.oracle.com/pls/apex/f?p=26095 with
userid: AMOL.PATIL@VYOMLABS.COM
pass : Unicorn@123

Code in execute JavaScript page load section:

 var previous=null;
 var flag;
 $("td[headers=DEPTNO]").each(function() {


 if(previous==null){
      previous=$(this).text();
      flag='true';
  }

 if($(this).text()==null ||$(this).closest('tr').next().find('[headers="DEPTNO"]').text()==null) {

 }
 else
 { 
   if($(this).text()!=$(this).closest('tr').next().find('[headers="DEPTNO"]').text()) {
    previous=$(this).text();
    if(flag=='false')
      flag='true';
    else
    {
    flag='false';

    }
   }

  if(previous==$(this).text()&& flag=='false') {

    flag='true';

    $(this).closest('tr').after('<tr><td></td><td></td><td></td></tr>');
    $(this).closest('tr').next().addClass("myclass");
  }
}

 }); 

code for inline css section of page:

table.uReportStandard > tbody tr.myclass > td 
{
    background-color:red !important;
}

Output : Similarly you can also implement same thing by just changing headers.In your case it may be FAMILYID which will replace DEPTNO here. Please try this code ...




回答2:


I actually just went about using a SQL workaround using the LAG command. Used that as a flag to indicate when value has changed and set the CSS command for the event. Thanks @Piyush for the suggestion to use a flag!



来源:https://stackoverflow.com/questions/28417837/sql-add-a-border-bottom-when-column-value-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!