#Data does not appear when placing the currentRow

1 messages · Page 1 of 1 (latest)

bleak sequoia
#
{{function(){
let colors = {
    'active':'Green',
    'inactive':'orange',
    'suspended':'Red',
    'deleted':'purple'
};
return colors[currentRow.currentstatus]
}()}}

I am trying to color the row like I did before in another table but this time it is not taking my data.

export default {
    run: (orderList) => {
        return orderList
            .filter(order => 
                            order["orders.orderid"] ||
                            order["entity.customerid"] ||
                            order["orders.endtime"] ||
                            order["entity.currentstatus"] ||
                            order["entitytype.entitytypename"] ||
                            order["entity.description"]
                         )
            .map(order => ({
            "orderid": order["orders.orderid"],
            "customerid": order["entity.customerid"],
            "endtime": parseInt(order["orders.endtime"], 10),
            "currentstatus": order["entity.currentstatus"],
            "entitytypename": order["entitytype.entitytypename"],
            "description": order["entity.description"]
        }));
    }
}
feral arrowBOT
#

Hey There,

We've registered your query, and our team will get back to you soon.

Regards,
Pranav

#

Hello, I'm AppySmith, your support bot for all things Appsmith! To address your
issue with coloring the table row based on the status, you should ensure that
you are correctly referencing the data field in your table widget. From the code
you've provided for the colors function, it seems you are using
currentRow.currentstatus. Make sure this field exactly matches the key in your
order list data after you've transformed it. Here are a few steps you can follow
to resolve the issue: 1. Verify that the transformation code in export default
is correctly mapping the currentstatus field from your data source to the new
object. 2. Check if the keys used (like entity.currentstatus) match the
structure of your incoming data. 3. Ensure that the column name in your table
widget matches the key expected by the JavaScript function for currentstatus.
If you have ensured the above points and it's still not working, there might be
an issue with the other parts of your implementation, such as the configuration
of the table widget or properties. Can you please provide more details about how
you have set up the color coding in your Appsmith application? This would help
me assist you better. If you don't find my response helpful, you can request to
speak to a human agent

#

Make sure you are using the correct case for the status.

bleak sequoia
#

These are what autocomplete provides and I have verified and it is correct.

For some strange reason it takes all records as empty.

feral arrowBOT
#

If your table is considering all records as empty, there might be an issue with
how the data is being sent to the table or how the table is interpreting the
data. Please check the following: - Ensure the data structure passed to the
table widget aligns with the expected data structure. The keys you use in your
map function after filtering should match the keys used within the table. - Make
sure there's no data type mismatch. For example, if endtime expects a number,
ensure it's parsed correctly. - After applying the transformation logic, ensure
the resulting data isn't an empty array. You could add a console log after the
mapping to verify the data structure. - Verify that any filtering conditions
before the map function aren't filtering out all your records unintentionally. -
Lastly, check if there are any errors in the browser's developer console that
could provide hints about what's going wrong. You may have to debug by
simplifying your run function and incrementally add to it to find the exact
point of failure. If the error persists, could you provide details on how you're
setting the table's data and binding the color transformation function? If you
don't find my response helpful, you can request to speak to a human agent

faint geyser
#

hi @bleak sequoia , your approach looks correct. Is there any chance that one of the statuses is undefined, null, or a value that does not exist in your colors object?

If your function fails on one row, it could affect the display on all rows. To avoid this, you can add optional chaining, and an OR operator, to provide a default color, or fallback value.

return colors[currentRow?.currentstatus] || 'grey'
feral arrowBOT
#

The suggestion to add optional chaining and a fallback color to your function is
a good practice to handle any potential undefined or unexpected values in your
data. Here’s an updated version of your function using optional chaining and a
fallback color: javascript let colors = { 'active': 'Green', 'inactive': 'orange', 'suspended': 'Red', 'deleted': 'purple' }; return colors[currentRow?.currentstatus] || 'grey'; With this updated function, if
currentstatus is undefined, null, or a value that's not a key in your
colors object, the function will return 'grey', ensuring that there is always
a valid color value returned for every row. This should prevent the function
from negatively affecting the display of your table rows in case there is an
issue with one or more rows' data. Make sure to update your table's cell
background color or cell style property to use this new function, and check if
it resolves the issue. If you continue to face problems, please provide any
error messages or describe the behavior you are observing to help me understand
the issue better. If you don't find my response helpful, you can request to
speak to a human agent

bleak sequoia
#

I have solved the problem.

In the end it was all because when resetting the component when changing between APIs within the table, the information was lost.

So I made a global state for my selector and avoid that reset widget.

Thanks for the help!

feral arrowBOT
#

I'm glad to hear that you were able to solve the problem! It's good to know that
by managing the global state for your selector, you prevented the reset of
widgets when switching between APIs. If you have any more questions or need
further assistance with your Appsmith application, feel free to ask. Helping you
succeed with Appsmith is my goal. Have a great time building with Appsmith! If
you don't find my response helpful, you can request to speak to a human agent