Responsive Sidebar With Treeview

Good afternoon!
The source code of the example of that functionallity is empty.
Would you show me how to implement it?

Thanks in advance!

14 Replies

SP Sowmiya Padmanaban Syncfusion Team March 13, 2020 06:49 AM UTC

Hi Társis,  
 
Greetings from Syncfusion support. 
 
We suspect that your reported problem is that the source tab is empty in Sidebar component. We have checked this reported issue from our end, but Source Tab is loading the code block of Sidebar component properly.  
 
Refer the  attached video. 
 
 
For your reference, we have prepared a sample with details on responsive Sidebar. 
 
Responsive Sidebar: 
 
When you set the MediaQuery property for Sidebar component. It closes the sidebar automatically when it reaches the specified mediaQuery value. Refer the below code snippet. 
 
  <EjsSidebar HtmlAttributes="@HtmlAttribute" Width="290px" Target=".main-content" @ref="Sidebar" MediaQuery="(min-width: 600px)"> 
            <ChildContent> 
            </ChildContent> 
  </EjsSidebar> 
 
Refer the below link for Responsive sidebar. 
 
 
TreeView inside the Sidebar: 
 
You have to declare the Treeview component inside the Sidebar within child content tag to make it render inside Sidebar. Refer the below code snippet. 
 
  <EjsSidebar HtmlAttributes="@HtmlAttribute"  Width="290px" Target=".main-content" @ref="Sidebar" MediaQuery="(min-width: 600px)"> 
            <ChildContent> 
                        <!-- Treeview element declaration --> 
                        <EjsTreeView CssClass="main-treeview" @ref="TreeView" ExpandOn="@Expand" TValue="TreeData"> 
                            <TreeViewFieldsSettings Id="nodeId" Text="nodeText" IconCss="iconCss" DataSource="treedata" HasChildren="hasChild" ParentID="pid"> 
                            </TreeViewFieldsSettings> 
                        </EjsTreeView> 
                    </div> 
                </div> 
            </ChildContent> 
        </EjsSidebar> 
 
Please, check the following links to know more about Sidebar. 
 
 
 
API Reference: 
 
 
 
To more about the TreeView component. Refer the below link. 
 
 
 
API Reference: 
 
 
 
we have prepared a sample based on your requirement for Sidebar with TreeView component.  
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



PG Pon Geetha A J Syncfusion Team March 16, 2020 05:58 AM UTC

Thank you for your answer. But I need the sidebar like a navigation menu. In your sample, if I change the page, the sidebar desapears, because it is in on especific page. 
How could I reach that? 
----------------------- 
 One more question, 
 
How can I do to colapse Sidebar when the user clics outside it? 



SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team March 16, 2020 07:12 AM UTC

Hi Társis, 
 
Greetings from Syncfusion support. 
 
Query 1: If i change the page, the sidebar desapears, because it is in on especific page 
 
Solution: 
 
We have looked into your query on EJ2 Sidebar. For your information, if you need the same Sidebar in expanded state when navigating to other pages of the application. You need to add the Sidebar in the MainLayout.razor. 
 
We have prepared a sample, in which we have rendered the Sidebar in the MainLayout.razor page to avail it in all the pages of the application to meet your requirement. 
 
Also, we have added the navigation bar inside the Sidebar component. So, we can use the navigation bar inside the Sidebar for navigating to other pages of the application. 
 
Query 2: How can I do to colapse Sidebar when the user clics outside it?  
 
Solution: 
 
When setting the CloseOnDocumentClick property as true, Sidebar will collapse when you click anywhere outside the Sidebar element in the page. 
 
Please, download the sample from the below. 
 
Sample:  
  
 
  
  
API Reference:  
  
  
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 



Társis March 16, 2020 03:12 PM UTC

Thank you for your quick answer. It worked, but I needed that the sidebar colapse only in "mobile mode"  when the user click outside the sidebar. In larger screens I would like the sidebar would stay expanded. How could I manage that? In my application I didn't get how to make the sidebar occupate the entire height of the window. I'm sending you a sample. In the opening page you can see the sidebar creates a scroll.

Attachment: GAFNETBlazor_d010c32d.zip


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team March 18, 2020 05:10 PM UTC

Hi Társis, 
 
We have checked your expected requirement with Sidebar. You can closeOnDocumentClick property of Sidebar to achieve your expected requirement of closing the Sidebar when clicking anywhere in the document except the Sidebar element. To find whether your using device, we can use JSInterop method call from server to client script function. 
 
We have prepared a sample to achieve your expected your requirement. Please, download the sample from the following link. 
 
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 



Társis March 18, 2020 11:11 PM UTC

Thank you for your answer! The part of the control ocupate the entire height worked, but with your sample the Sidebar doesn't close anymore, no matter the device.
I'll tell what I did.
- Run the application on Chrome and click with the right button in the screen.
- Select "Inspect"
- Select the device (S9, for example)
- Click in the menu and it opens
- Select any option.
Now, when a click outside the Sidebar, in the document, the Sidebar doesn't close anymore. It only closes if I click in the "toggle" button again.


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team March 19, 2020 09:03 AM UTC

Hi Társis, 
 
We have looked into your reported problem. We would like to let you know that EJ2 components are built from scratch to adapt any responsive resolution (mobile screen dimension). 
 
If you try to check the responsive behavior of EJ2 components using the Browser’s emulator option, then please refresh the page and check the expected behavior. Because, we have added specific functionalities to the EJ2 components based on the userAgent.  
 
So, if you just switch to the emulator from browser in a desktop dimension, then source level functionalities written specific to responsive dimension will not be compiled. So, component will work as it is rendered in a desktop resolution. 
 
We suggest you refresh the page with Sidebar and check the provided solution. We tested the sample and it works properly as like you expected. 
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 



Társis March 19, 2020 12:37 PM UTC

It worked perfectly. Thank you very much!


Társis March 19, 2020 03:16 PM UTC

Hi again,

in your sample, the application worked, like I said, perfectly, but for some reason it doesn't in mine. I did a copy and paste in the Sidebar page, but I couldn't get it working. Would you give a look on it?
Thanks in advance!

Attachment: GAFNETBlazor_d27a6ff0.zip


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team March 20, 2020 05:19 AM UTC

Hi Társis, 
 
Sorry for the inconvenience.  
 
We have modified your sample with proper JSInterop function to call from server method like depicted in the below follow-up. 
 
@code { 
 
    [Inject] 
    public IJSRuntime JSRuntime { get; set; } 
    object[] eventParameters = new object[] { }; 
    public async Task afterCreated(Object args) {  
      await   JSRuntime.InvokeAsync<bool>("onCreated"); } 
    } 
  
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 



Társis March 20, 2020 03:38 PM UTC

Thank you very much. Now it works. Good job!


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team March 23, 2020 02:15 AM UTC

Hi Társis, 
 
Welcome. Please, get back to us if you need any further assistance. We will be happy to assist you. 
 
Regards, 
Shameer Ali Baig S. 



UC Ulisses Correia de Araujo Neto June 22, 2020 10:19 PM UTC

Társis

Vi que você é Brasileiro, gostaria de tirar uma dúvida sobre o menu.

Ulisses


SP Sowmiya Padmanaban Syncfusion Team June 23, 2020 10:20 AM UTC

Hi Ulisses Correia de Araujo Neto,  
 
Can you please share the details regarding your requirement with menu component. It will help us to provide you the prompt solution. 
 
Regards,  
Sowmiya.P 


Loader.
Up arrow icon