0

I am using C# MVC for my project.

In Home page, I am rending one action using razor syntax.

Index.chtml Page

<div>
    @Html.RenderAction("OrganizationManagerData","Home")
</div>

When I first time load Index page, "OrganizationManagerData" method also render and it shows employee data with all who are working under him/her in Tabular format. Logged In manager can do many things in that like provide feedback to individual, give task, submit performance report of individual to higher authority, so on.

We have one more option on Index Page "Filter" when Manager clicks on it, it will show popup and can select the filter which needs like good performer, avg Performer, by task, so on.

What I want to achieve is when manager select Filters and click Apply, I want to re-render the table so that it will display filtered data.

What I am thinking is When user will click on "Apply", will call again DB and will show filtered Data

Is it good approach however I don't know how to re-render the "OrganizationManagerData" action again on Apply Click? Or Is it any better way to do it?

What is usually best practice to display intuitive dashboard which have loads of data.

Would like to hear your opinion.

Thanks in advance.

I just thought of maybe I will call Ajax for OrganizationManagerData and it will return json format which I will use to format table in JS.

However for this have to write lots of html in Javascript.

  • You can't reload a partial view using javascript alone, but if you have a controller method that returns your partial view you can use that to effectively reload the view. [This Question and answer](https://stackoverflow.com/q/1570127/1048425) covers how to do that in JQuery. If you aren't using Jquery this is still possible with just plain JS. – GarethD Nov 25 '22 at 15:28
  • @GarethD "OrganizationManagerData" is not rending partial view, it is actual view – Ankit Cheepad Nov 25 '22 at 15:56
  • It would be odd to put a view inside a view, it would be more normal to have partial views rendered within a view (in your case "index.xhtml"). Nonetheless the sentiment remains, you can call that URL using ajax and replace the contents of your current page with the refreshed view from the controller. That means you don't need to format you data in js, you are receiving a rendered view from the controller – GarethD Nov 25 '22 at 16:03

1 Answers1

0

I have hide the rows which are not matching with my filter condition using JavaScript.