0

I've implemented a ribbon button that updates an entity field, based on the entity selected in a dashboard view. After I update the entity field through js, I need to refresh the dashboard view to redisplay the view with the updated field value.

What's the most elegant way to do this? I could execute js to reload the whole page, but would be the worst case scenario. Can you recommend a way to refresh only a specific view on a dashboard to display updated data?

abdelaziz maroc
  • 117
  • 1
  • 2
  • 14

2 Answers2

1

Let's say this is your main div container that holds your entire dashboard html

<div id="main-container"> </div>

Then if you're already using jQuery

$('.updateBtn').on('click', function(){
  // update your entity field here
  $.ajax({
    url : 'your-dashboard-url',
    type : 'GET',
    // data : some object in case you want to pass something to server
    dataType : 'html'
  }).done(function(rdata){
        $('#main-container').html(rdata); 
  });
});
Arkantos
  • 6,530
  • 2
  • 16
  • 36
  • thanks , but how can I call this function every 30 seconds and without click event – abdelaziz maroc Mar 03 '15 at 16:04
  • you can keep the whole ajax code inside a function say `getDashboardContent` and use that in `setInterval(getDashboardContent, 30000)` – Arkantos Mar 03 '15 at 16:10
  • But are you sure there will always be updated content on server side every 30seconds ? If not, then you're unnecessarily making requests to get same content :) – Arkantos Mar 03 '15 at 16:11
  • That's just jQuery way of selecting all elements with `updateBtn` class – Arkantos Mar 03 '15 at 16:47
0

We have a Custom report in IFRAME at our dashboard and we have to apply some CSS Styles on that report.

With following lines of code, i was able to get to the report and apply styles.

var ContentIframe = window.top.document.getElementById('contentIFrame0');
if(ContentIframe!=null)
{
var DashboardIframe=ContentIframe.contentDocument.frames["dashboardFrame"]
if(DashboardIframe!=null)
{
   //DashboardIframe.document.frames["IFRAME_SalesTrend"].document.getElementById("compatibilityNotification").style.display = "none";

We have Activities View on dashoboard, I can get and refresh it like below.

 DashboardIframe.document.getElementById("Activities").control.refresh();
}

It works and you can also test it in the developer tools Console. It is able to find that element. enter image description here

Dot_NET Pro
  • 2,095
  • 2
  • 21
  • 38
  • thank you for answer but that doesn't work :/
    Message Error : 'unable to get property 'refresh' of undefined or null reference'
    – abdelaziz maroc Mar 03 '15 at 09:46
  • `DashboardIframe.document.getElementById("Activities").control.refresh();` I can't find `.Control.refresh()` that handle the error and sorry for my english :/ – abdelaziz maroc Mar 03 '15 at 10:17
  • @abdelazizmaroc that is because you do not have the `Activities` view on your dashboard, find the name of your `View` that you want to refresh and replace it with `Activities`. Thankx – Dot_NET Pro Mar 05 '15 at 05:52
  • I had replace `"Activities"` with the Id of my views but I still had the same error – abdelaziz maroc Mar 05 '15 at 09:49
  • @abdelazizmaroc view cannot be Null. As i have attached the screenshot, you have to use all the code. – Dot_NET Pro Mar 05 '15 at 11:37