We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Bind multiple LinearGauges to model

Is it possible to bind an arbitrary number of linear gauges to an MVC model or viewbag? And are there any sorts of examples?

I would ideally like to create cards inside a foreach of my model. I am having some difficulty making progress on this front.

Many thanks in advance,
Matthew

1 Reply

BP Baby Palanidurai Syncfusion Team June 26, 2019 09:50 AM UTC

Hi Matthew, 

Greetings from Syncfusion. 

We have analyzed your query. We have prepared a sample based on your requirement. In that sample, we have rendered multiple linear gauges based on the length of data collection that is from controller page.  
Please find the below code snippet to achieve this requirement, 
Controller.cs            
          DataTable dt = new DataTable(); 
            dt.Columns.Add("Name"); 
            dt.Columns.Add("FullName"); 
            dt.Columns.Add("Stock"); 
            dt.Columns.Add("MaxStock"); 
            dt.Columns.Add("AvailableStock"); 
            dt.Rows.Add(new Object[] { "T13", "PM01 T13", 1, 100, 34 }); 
              .. . // Add more data 
 
            List<LinearData> gauges = new List<LinearData>(); 
 
            foreach (DataRow row in dt.Rows) 
                gauges.Add(CreateLinearGauge(row)); 
 
            ViewBag.GaugeData = gauges; 
 
.CSHTML 
 
 
@{ 
            var count = 0; 
            foreach (LinearData gauge in ViewBag.GaugeData) 
            { 
                @(Html.EJ().LinearGauge("PointerGauge" + (++count)) 
                 ) 
            } 
        } 


If you are still facing any issues, kindly revert us with modify the above sample or provide more information about your requirement which will be helpful in furthermore analysis and provide you the solution sooner. 

Regards, 
Baby. 


Loader.
Live Chat Icon For mobile
Up arrow icon