Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to dynamic data bind in dhtmlx gantt chart


with dynamic data use for loop

What I have tried:

//for (var i = 0; i < 5; i++)
                   //{
                   //    data.push({
                   //        "data" :  { "id": 1, "text": "Strand Pickling", "Job": "3.1.9", "ONumber": "1", "Itm": "0.89 MM NT BW", "Qty": "50", "start_date": "28-03-2017", "end_date": "01-04-2017 21:00:00", "ItemName": "2", "duration": "3", "progress": 0.2, "open": true },
                   //    })
                   //}
Posted
Updated 25-May-23 20:46pm

1 solution

foreach (DataRow dr in dt.Rows)
           {
               if (buffer == string.Empty || buffer != dr["SectionName"].ToString())
               {
                   parent = 0;
                   ProSchedular.Add(new Production(i + 4, dr["SectionName"].ToString(),emptydata,emptydata,emptydata,emptydata, dr["sdate"].ToString(),
                                                       dr["edate"].ToString(), parent));
                   parent = i + 4;

                   ProSchedular.Add(new Production(i + 5, dr["machines"].ToString(), dr["JobNo"].ToString(), dr["OrderNumber"].ToString(), dr["ItemName"].ToString(),
                                  dr["ProductionQuantity"].ToString(), dr["sdate"].ToString(), dr["edate"].ToString(),parent));

                   buffer = dr["SectionName"].ToString();
               }
               else
                   ProSchedular.Add(new Production(i + 6, dr["machines"].ToString(), dr["JobNo"].ToString(), dr["OrderNumber"].ToString(), dr["ItemName"].ToString(),
                                 dr["ProductionQuantity"].ToString(), dr["sdate"].ToString(), dr["edate"].ToString(), parent));

               i = i + 7;
           }


           return ProSchedular;
       }
       catch (Exception ex)
       {
           logwriter.Debug(ex.Message.ToString());
           //objMas.PrintLog(" Pageid : " + pageid + " First Time page load  Fetch Details From CardMaster : ",ex.Message.ToString());
           return ProSchedular;
       }

   }
     public class Production//pagedetail
     {
         public int id = 0;
         public string start_date = "", end_date = "", text = "", Job = "", ONumber = "", Itm = "", Qty = "";
         public int parent;
         public bool open;
         public string buffer = "";

         public Production(int  i,string section,string jobNumber,string OrdNum,string Item ,string qty,string SDate, string EDate,int p)
         {
             if (buffer == string.Empty || buffer != section)
             {
                 id = i; text = section; Job = jobNumber; ONumber = OrdNum; Itm = Item; Qty = qty; start_date = SDate; end_date = EDate;open = true;
                 parent = p;buffer = section;
             }
             else
             {
                 id = i; text = section; Job = jobNumber; ONumber = OrdNum; Itm = Item; Qty = qty; start_date = SDate; end_date = EDate; open = true;
                 parent = p;
             }
         }
     }
 
Share this answer
 
Comments
[no name] 21-Jan-17 9:13am    
Are you a solo entertainer?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900