Yii Framework Forum: Slow Bandwidth Solution To Selecting Many Items - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Slow Bandwidth Solution To Selecting Many Items Rate Topic: -----

#1 User is offline   Jay Haase 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-May 11

Posted 04 October 2011 - 02:57 PM

Hello Yii Friends,

I am working on a website that must function well in low-bandwith situations (the website will be used in developing countries). I need some help with ideas for a page with the following requirements:

  • A user has 1,000 clients stored in their database.
  • The system displays a list of all the clients.
  • The user indicates/marks some or all of the clients as being served (no communication occurs over the Internet with server during this process)
  • The user tells the system to save the list of served and not served clients.
  • The system saves the data and informs the user.


I am currently using a CGridView with buttons to select and unselect a client. A controller method is called when a client's selection status is changed via one of the buttons. The buttons look like checkboxes, and only one is displayed at a time. This is proving to be very reliable, easy for the users, and too slow for use in environments with low bandwidth.

I have been thinking about trying to use two list boxes. Where a user can move clients from one "Not Served" list box to the "Served" list box. Then the data would only be communicated to the controller when a user clicks a submit button.

Thanks in advance for any help,
Jay.
0

#2 User is offline   jodev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 10-January 11
  • Location:The Netherlands

Posted 05 October 2011 - 06:39 AM

Why not use a CGridView with a CCheckBoxColumn added to it? Then the user can check off all served clients, hit the submit button and the controller processes each checked row server side. The only bandwidth you'll then have is the form submission.

In pseudo code, your controller action would look something like this:

public function actionClients()
{
    if isset POST
    {
        foreach submitted checkbox
            update the model
            save the model

        redirect to desired page
    }

    render the form
}


Make sure to enclose the whole CGridView within the form.
0

#3 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 529
  • Joined: 09-April 10

Posted 05 October 2011 - 07:21 AM

I think this will only work for a single CGridView page. AFAIK, when you move to another page (Ajax or regular POST), the previous page's selection will be lost. You'll need to keep a record, in javascript, of selected boxes until you submit. Can someone confirm this?

Matt

View Postjodev, on 05 October 2011 - 06:39 AM, said:

Why not use a CGridView with a CCheckBoxColumn added to it? Then the user can check off all served clients, hit the submit button and the controller processes each checked row server side. The only bandwidth you'll then have is the form submission.

In pseudo code, your controller action would look something like this:

public function actionClients()
{
    if isset POST
    {
        foreach submitted checkbox
            update the model
            save the model

        redirect to desired page
    }

    render the form
}


Make sure to enclose the whole CGridView within the form.

0

#4 User is offline   Jay Haase 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-May 11

Posted 05 October 2011 - 08:02 AM

View Postwaterloomatt, on 05 October 2011 - 07:21 AM, said:

I think this will only work for a single CGridView page. AFAIK, when you move to another page (Ajax or regular POST), the previous page's selection will be lost. You'll need to keep a record, in javascript, of selected boxes until you submit. Can someone confirm this?

Matt


@Matt, You are correct.
0

#5 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 529
  • Joined: 09-April 10

Posted 05 October 2011 - 08:48 AM

That should be pretty easy, especially with jQuery. I would submit the result set with Ajax - saving more bandwidth.
0

#6 User is offline   Jay Haase 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-May 11

Posted 10 October 2011 - 05:39 PM

View Postwaterloomatt, on 05 October 2011 - 08:48 AM, said:

That should be pretty easy, especially with jQuery. I would submit the result set with Ajax - saving more bandwidth.


WaterlooMatt,

That's what I like to hear - easy! :-)

Do you mean it would be easy to keep a list of the selected items when moving from page to page?
0

#7 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 529
  • Joined: 09-April 10

Posted 11 October 2011 - 03:03 AM

Yes. I would extend CGridView. This widget should generate a grid, a submit button, and inject some JS into the page keep track of the selected items. The submit button would send the list (ids?) to the controller. I've gotta run to work now but will try to come up with something tomorrow.

Cheers,

Matt
0

#8 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 529
  • Joined: 09-April 10

Posted 23 October 2011 - 10:11 AM

Sorry - haven't had a chance to look into it. Did you come up with a solution yet?
0

#9 User is offline   Jay Haase 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-May 11

Posted 23 October 2011 - 11:03 AM

View Postwaterloomatt, on 23 October 2011 - 10:11 AM, said:

Sorry - haven't had a chance to look into it. Did you come up with a solution yet?


Not yet. I am also busy working on another project. I was trying to let this bubble around in my head so that I might think of a super clever idea.
0

#10 User is offline   Jay Haase 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-May 11

Posted 18 November 2011 - 07:11 AM

So far, I have not changed the basic interface that I am using. Although I did find some simple ways to speed things up a bit in low bandwidth situations:

  • I turned off debug mode in production.
  • I compressed by CSS files with the extension DynamicRes


Jay.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users