This is a migrated thread and some comments may be shown as answers.

[Solved] Load on demand example - How to concatenate values and show spaces?

5 Answers 231 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 21 Mar 2008, 01:49 PM
Hi..
In the load on demand example I'm trying to display multiple columns by
concatenating several fields with spaces between... so I retain the performance of the load on demand and get the 'visual' of the binding (takes much longer)

Like this...

    for (int i = itemOffset; i < endOffset; i++)
                {
                    RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString()+"       "+LASTNAME+"         "+FIRSTNAME, data.Rows[i]["CompanyName"].ToString() ));
                }


But the spaces are ignored.. how do I 'display' the 'needed' spaces ? do I need to override the render ?  &nsp - doesn't work
thanks!

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Mar 2008, 01:53 PM
Hi Jon Elster,

Please find attached a test project which demonstrates the approach you have described. Sets of spaces are displayed correctly for each selected item in the RadComboBox. Please review it and let me know if I have missed something.

Thank you in advance for your cooperation.

Best wishes,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jon
Top achievements
Rank 1
answered on 24 Mar 2008, 02:09 PM
The data binding takes 'forever' I have 50K records...
I also get the IE message...

"Stop running this script? A script on this page is causing IE to run slowly..."

I'd like to use the load on demand example with out the databinding.. much faster.. how do I format my text to 'keep' the spaces?
So they line up - like in a grid

the spaces, below are removed when adding the Items.. how can I 'keep' the spacing

_name =

String.Concat(data.Rows[i]["Name"].ToString().Trim(),"                     ", data.Rows[i]["CITY"].ToString().Trim(), "             ", data.Rows[i]["STATE"].ToString().Trim());

this.RadComboBoxSelect.Items.Add(new RadComboBoxItem(_name, data.Rows[i]["ID"].ToString()));

thanks again!
0
Simon
Telerik team
answered on 24 Mar 2008, 03:48 PM
Hello Jon Elster,

I have attached a sample project to my last post. Could you examine it and tell me how to modify it in order to reproduce this erroneous behaviour?

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brian
Top achievements
Rank 1
answered on 24 Mar 2008, 05:55 PM
Hi..
Use the load on demand example - so it's FAST... add more fields to the item.. see the BOLD below.. and try to have the 3 columns spaced accordingly..... thanks!  
Databind in too sloooooooooooooow...

  protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string sql = "SELECT * from Customers WHERE CompanyName LIKE '" + e.Text + "%'";

            SqlDataAdapter adapter = new SqlDataAdapter(sql,
                ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
            DataTable data = new DataTable();
            adapter.Fill(data);

            try
            {

                int itemsPerRequest = 10;
                int itemOffset = e.NumberOfItems;
                int endOffset = itemOffset + itemsPerRequest;
                if (endOffset > data.Rows.Count)
                {
                    endOffset = data.Rows.Count;
                }
                if (endOffset == data.Rows.Count)
                {
                    e.EndOfItems = true;
                }
                else
                {
                    e.EndOfItems = false;
                }
                for (int i = itemOffset; i < endOffset; i++)
                {
                    RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString()+"       "+Address+"        "+CITY, data.Rows[i]["CompanyName"].ToString() ));
                }

                if (data.Rows.Count > 0)
                {
                    e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                }
                else
                {
                    e.Message = "No matches";
                }
            }
            catch
            {
                e.Message = "No matches";
            }
        }


0
Simon
Telerik team
answered on 26 Mar 2008, 02:12 PM
Hello Tim Warren,

I tried the code you have sent in the Load On Demand from SQL example locally and everything worked as expected and rather fast.

Most probably the connection to your data base server is slow. You could check, while debugging, how long does it take to execute the data base query. This should give you a clue whether the server connection slows things down or not.

I hope this information helps.

Best wishes,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Simon
Telerik team
Jon
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Share this question
or