web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power apps, Model driv...
Power Apps
Unanswered

Power apps, Model driven app

(0) ShareShare
ReportReport
Posted on by 10

Hi All, this is probably my first question here. I want to add background colors in my subgrid (Editable Grid View), I want to add different colors for the different columns, I am using the web resource as JS file, here is my code.

{
function formatColumn(rowData, userLCID) {
debugger;
var style = '<style> ';
style += '.wj-cells .wj-row div:nth-child(4) { background: red !important;}';
style += '.wj-cells .wj-row div:nth-child(5) { background: yellow !important;}';
style += '</style>'
document.body.innerHTML += style

}

}

It will not change when i publish my app. This script works when I run it on console. Please find me the method to do this, thanks

FarazAli_0-1661801660019.png

 

Categories:
  • AhmedSalih Profile Picture
    6,680 Moderator on at

    Hello, @FarazAli, You need to assign the web resource you created to your View's Columns . 

    Go to your View and Edit, then Click Switch to Classic> Select the Column and select the web resource & the Function name. Lastly, Save and Publish the View after saving the Columns settings in the classis settings:

    AhmedSalih_0-1661803904452.png

     

     


    If my reply helped you, please give a 👍, & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.com

     

     

     

  • FarazAli Profile Picture
    10 on at
    Spoiler (Highlight to read)
    I did the same as you mentioned. Nothing happened. 
    I did the same as you mentioned. Nothing happened. 
  • FarazAli Profile Picture
    10 on at

    @AhmedSalih is there any other option to apply css using web resource to a column? 

  • AhmedSalih Profile Picture
    6,680 Moderator on at

    Hello, @FarazAli, not to many resources about the css but this video will give you some direction. 

    https://www.youtube.com/watch?v=2OdqFHfl0Io

     


    If my reply helped you, please give a 👍, & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.


    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.


    Visit my Blog: www.powerplatformplace.com

     

     

  • FarazAli Profile Picture
    10 on at

    @AhmedSalih thanks for your response, I think I asked my question in some tricky way, this is my scenario please have a look, this is my view

    FarazAli_0-1661807629580.png

    I go to customize view, then in the first column I added web recourse and  function name as well.
    this is my webresource js code
    function formatColumn(rowData, userLCID) {
    debugger;
    var style = '<style> ';
    style += '.wj-cells .wj-row div:nth-child(4) { background: red !important;}';
    style += '.wj-cells .wj-row div:nth-child(5) { background: yellow !important;}';
    style += '</style>'
    document.body.innerHTML += style
    }

    when published the app, the code wont work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard