Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / UltraGrid data binding at runtime.

UltraGrid data binding at runtime.

New Discussion
SreeRamaSaran
SreeRamaSaran asked on Sep 26, 2008 8:53 PM

Hi,

This is SreeRam and new to NetAdvantage. I’ve a situation where I’ve to go for UltraGird for various functionalities supported by it. Basically I want to know a few things about this control.

I’m using UltraGrid in an experiment basis in my application. My present requirement is

1. to bind the ultragrid at runtime because of not having direct access to Data Access layer. I used to get the data through Business Logic Layer.

2. to hide some of the columns which are not necessary to display.

3. to add columns at particular location (example a column for S.No which will be displayed as the first column and should not be editable and it will be auto generated) for providing additional information and needs to be updated frequently.

4. needs to bind some of the columns with another list or datasource (example I’ll get a column “CustomerId” from the data source. I need to bind that column to another data source so that, In the place of Customer Id, I’ll get the name of the customer.)

Any help will be appriciated.

Regards

SreeRam.

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Aug 26, 2008 3:02 PM

    1) You can bind the grid to a data source at run-time. The best thing to do is call the SetDataBinding method on the grid. 

    2)  Typically, you would handle the InitializeLayout event of the grid and do something like this: 

    e.Layout.Bands[0].Columns[columnName].Hidden = true;

    3)  You could add an unbound column to the grid. Again, I would use the InitializeLayout event for this. You would add the column using the Columns collection's Add method. You will probably want to set the DataType of the Column and set column.Header.VisiblePosition to control it's placement. 

    4) It sounds like you want a dropdown list in the cell. A dropdown would allow the user to choose an item from a list and also handles converting an id into a more user-friendly display text. This KB article should help point you in the right direction:  HOWTO:What is the best way to place a DropDown list in a grid cell?

    • 0
      SreeRamaSaran
      SreeRamaSaran answered on Aug 26, 2008 4:14 PM

       Thanks Mr. Mike.

       However I worked it out in the following way. Please suggest me whether it is correct or not? If there is any best way please mention with the sample code [I think you will understand my requirement by seeing the below code. Most important thing to remember is that I'm getting the data source from the business logic layer instead of direct access to datasets].

       I found another problem with the column "EntryTime". There I need to display the time or both date and time of entry instead of onlf date.But the grid displays only date. How can I format the column so that it displays Date and Time or only Time?

       

      *********************************************************************************************************************

      private void FillTodaysQueue()
              {
                  QueueMaster queueMaster = new QueueMaster();
                  if (!ugQueue.DisplayLayout.Bands[0].Columns.Contains("ElapsedTime"))
                  {
                      ugQueue.DisplayLayout.Bands[0].Columns.Add("ElapsedTime", "Elapsed Time");
                  }
                 
                  ugQueue.DataSource = queueMaster.GetTodayQueue();
                  ugQueue.Refresh();

                  ugQueue.DisplayLayout.Bands[0].Columns["Sno"].Width = 30;

                  // Hide unneccessary columns
                  ugQueue.DisplayLayout.Bands[0].Columns["QueueId"].Hidden = true;
                  ugQueue.DisplayLayout.Bands[0].Columns["PatientId"].Hidden = true;
                  ugQueue.DisplayLayout.Bands[0].Columns["ConsultantId"].Hidden = true;
                  ugQueue.DisplayLayout.Bands[0].Columns["ExitTime"].Hidden = true;

                  ugQueue.DisplayLayout.Bands[0].Columns["EntryTime"].Header.Caption = "Entry Time";
                 
                  // Hide filter icon on unneccessary columns
                  //ugQueue.DisplayLayout.Bands[0].Columns["ElapsedTime"].AllowRowFiltering = DefaultableBoolean.False;
                  ugQueue.DisplayLayout.Bands[0].Columns["Sno"].AllowRowFiltering = DefaultableBoolean.False;
                  ugQueue.DisplayLayout.Bands[0].Columns["PatientId"].AllowRowFiltering = DefaultableBoolean.False;
                  ugQueue.DisplayLayout.Bands[0].Columns["EntryTime"].AllowRowFiltering = DefaultableBoolean.False;

                  //ugQueue.DisplayLayout.Bands[0].Columns["ConsultantId"].Width = 150;
                  //ugQueue.DisplayLayout.Bands[0].Columns["EntryTime"].Width = 125;
                  //ugQueue.DisplayLayout.Bands[0].Columns["ElapsedTime"].Width = 100;

                  //ugQueue.DisplayLayout.Bands[0].Columns["ElapsedTime"].Swap(ugQueue.DisplayLayout.Bands[0].Columns["Status"]);

                  FillValueLists();
                 
                  queueMaster.Dispose();
              }

              /// <summary>
              /// Displays Consultant Name instead of ConsultantId,
              /// Patient name instead of Patient Id, etc…
              /// </summary>
              private void FillValueLists()
              {
                  ugQueue.DisplayLayout.ValueLists.Add("PatientType");

                  ugQueue.DisplayLayout.ValueLists["PatientType"].ValueListItems.Add(0, "New");
                  ugQueue.DisplayLayout.ValueLists["PatientType"].ValueListItems.Add(1, "Old");
                  ugQueue.DisplayLayout.ValueLists["PatientType"].ValueListItems.Add(2, "Renew");

                  ugQueue.DisplayLayout.ValueLists["PatientType"].DisplayStyle = ValueListDisplayStyle.DisplayText;
                  ugQueue.DisplayLayout.Bands[0].Columns["PType"].ValueList = ugQueue.DisplayLayout.ValueLists["PatientType"];

                  ugQueue.DisplayLayout.ValueLists.Add("QueueType");
                  ugQueue.DisplayLayout.ValueLists["QueueType"].ValueListItems.Add(0, "Appointment");
                  ugQueue.DisplayLayout.ValueLists["QueueType"].ValueListItems.Add(1, "General");
                  ugQueue.DisplayLayout.ValueLists["QueueType"].ValueListItems.Add(2, "");
                  ugQueue.DisplayLayout.ValueLists["QueueType"].DisplayStyle = ValueListDisplayStyle.DisplayText;
                  ugQueue.DisplayLayout.Bands[0].Columns["QType"].ValueList = ugQueue.DisplayLayout.ValueLists["QueueType"];

                  ugQueue.DisplayLayout.ValueLists.Add("Status");
                  ugQueue.DisplayLayout.ValueLists["Status"].ValueListItems.Add(0, "Pending");
                  ugQueue.DisplayLayout.ValueLists["Status"].ValueListItems.Add(1, "");
                  ugQueue.DisplayLayout.ValueLists["Status"].DisplayStyle = ValueListDisplayStyle.DisplayText;
                  ugQueue.DisplayLayout.Bands[0].Columns["Status"].ValueList = ugQueue.DisplayLayout.ValueLists["Status"];
              }

    • 0
      SreeRamaSaran
      SreeRamaSaran answered on Aug 26, 2008 4:39 PM

      Once again Thanks Mr. Mike.

      I made changes to my code so that adding unbounded columns in the  InitializeLayout event. I specified the datatype and the visible position also.

      By the way I have another problem which I mentioned in my previous reply. Please consider my sample code and suggest the solution to that DateTime problem.

      Thanks a lot.

       With regards,

      SreeRam.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Aug 27, 2008 2:20 PM

         Set the MaskInput property of the DateTime column to "{date} {time}" and that should give you what you want. 

      • 0
        SreeRamaSaran
        SreeRamaSaran answered on Aug 28, 2008 3:58 PM

         Ya. It's working.

        Thanks.

        With Regards,

        SreeRam.

      • 0
        Ping
        Ping answered on Sep 26, 2008 6:35 PM

        How do I set the MaskInput so I can input fraction, that is less than one second in the cell? 

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 26, 2008 8:53 PM

        I don't beleive that fractions of a second are supported by the masking functionality in the grid. You can Submit a feature request to Infragistics.

         

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
SreeRamaSaran
Favorites
0
Replies
7
Created On
Sep 26, 2008
Last Post
17 years, 5 months ago

Suggested Discussions

Created by

Created on

Sep 26, 2008 8:53 PM

Last activity on

Feb 12, 2026 7:55 PM