Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#18399 closed defect (invalid)

Problem with More choices/Previous choices in filtering select.

Reported by: vish Owned by: vish
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:

Description

For two iteration clicking on “More choices” worked fine but after two iteration it blows away all the options. Dojo FilteringSelect? uses a parameter “pageStart” to control the display of records, each time “More choices/Previous choices ” is clicked “pageStart” is updated to the last count of previously displayed records.

We investigated and it looks that there is an issue in dojo when pageStart becomes greater than pageSize filteringSelect starts behaving incorrectly. We looked into the code in _SearchMixin.js and found following code snippet is causing problem:-

options.start += res.length;
                                                                                if(options.start >= res.total){
                                                                                        options.count = 0;
                                                                                }
                                                                        }else{
                                                                                options.start -= pageSize;

We modified this code as below and it worked fine.:-

options.start += res.length;
                                                                                if(options.start >= resPromise.total){
                                                                                        options.count = 0;
                                                                                }
                                                                        }else{
                                                                                options.start -= _this.pageSize;
c.count=_this.pageSize;

Attachments (4)

issue.jpg (9.5 KB) - added by vish 4 years ago.
1st_Iteration.jpg (16.4 KB) - added by vish 4 years ago.
2nd_Iteration.jpg (23.3 KB) - added by vish 4 years ago.
3rd_Iteration.jpg (21.5 KB) - added by vish 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by bill

Owner: set to vish
Status: newpending

OK, well maybe there is a problem, but can you make a test case to reproduce this error? We need a test case before we can check in any changes. Note that we do already have tests of paging through results, although I guess it doesn't go through many pages.

comment:2 Changed 5 years ago by vish

Status: pendingnew

Ok. I will make a test case to create this scenario, as i cannot send you my project related codes because of proprietary rights. Can you please try to recreate this issue by changing your paging test cases to iterate over more than 4-5 pages. I think it can catch this issue.

Thanks in Advance.

comment:3 Changed 5 years ago by bill

Status: newpending

I tried that. It works fine. Waiting for your test case.

comment:4 Changed 4 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed 4 years ago by vish

Attachment: issue.jpg added

Changed 4 years ago by vish

Attachment: 1st_Iteration.jpg added

Changed 4 years ago by vish

Attachment: 2nd_Iteration.jpg added

Changed 4 years ago by vish

Attachment: 3rd_Iteration.jpg added

comment:5 Changed 4 years ago by vish

Hello Team,

I am re-opening this ticket. I have created a test environment to catch this issue. I used following link to create this test environment:-

http://zendgeek.blogspot.in/2009/07/creating-nice-dojo-form-in-zend.html

you can refer this too in case of any query or can follow me.

Here is the directory structure of my test case:-

html_root

/application

/controllers

TestController?.php

/models /forms

TestForm?.php

/views

/scripts

/app

index.phtml

code of Controller Class of my test environment:-

<?php require_once('/var/TKLC/appworks/modules/diameter/forms/TestForm.php'); class App_TestController extends Zend_Controller_Action {

function indexAction() {

$form= new app_forms_testForm(); $this->view->form= $form;

}

/

  • Implements the URL for the store attached to the filtering select.
  • @return json string containing 35 store items. */

public function ajaxfilteringselectstoreAction() {

$this->PrepareAjaxResponse?();

set the options $options = $this->getFilteringSelectQueryOptions();

$data = array(); for ($i=$optionspageOffset?; $i <= 35; $i++) {

$data[] = array("name" => "abc".$i);

} $data = new Zend_Dojo_Data("name", $data); $this->_helper->json->sendJson($data);

} protected function PrepareAjaxResponse?() {

Zend assumes that incoming requests are for HTML pages. These two functions need to be called for each AJAX request. $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender();

} protected function getFilteringSelectQueryOptions($storeKey = "name") {

$options = array();

filtering parameters. $storeKeyVal = $this->getRequest()->getParam($storeKey); $idKeyVal = $this->getRequest()->getParam("id");

setting pageOffset and pageCount. $optionspageOffset? = intval($this->getRequest()->getParam("start")); $optionspageCount? = 10;

return $options;

}

}

code of Form Class:-

<?php form Class class app_forms_testForm extends Zend_Dojo_Form {

public $_selectOptions; public function init() {

$this->_selectOptions=array(

'1' => 'red', '2' => 'blue', '3' => 'gray', '4' => 'ffg', '5' => 'eef', '6' => 'dde', '7' => 'ccd', '8' => 'bba', '9' => 'aab', '10' => 'lmn', '11' => 'edf', '12' => 'pqr', '13' => 'xyz', '14' => 'zz', '15' => 'yy', '16' => 'xx', '17' => 'ww', '18' => 'vv', '19' => 'uu', '20' => 'tt', '21' => 'ss', '22' => 'rr', '23' => 'qq', '24' => 'pp', '25' => 'oo', '26' => 'nn', '27' => 'mm', '28' => 'll', '29' => 'kk', '30' => 'jj', '31' => 'ii', '32' => 'hh', '33' => 'gg', '34' => 'ff', '35' => 'ee', '36' => 'dd', '37' => 'cc', '38' => 'bb', '39' => 'aa', '40' => 'abc',

);

$this->setMethod('post'); FilteringSelect? $this->addElement(

'FilteringSelect?', 'filterselect', array(

'label' => 'Test FilteringSelect?', 'id' => 'testfilteringSelect', 'name' => 'testfilteringSelect', 'value' => 'blue', 'autocomplete'=>false, when we set multiOptions with an array containing 40 values we didnt found any issue. But when set store with 35 items then we faced mentioned issue.

'multiOptions' => $this->_selectOptions,

'error' => "The value entered is not valid.", 'pageSize' => 10,

)

);

}

} ?>

code for Index.phtml file:-

<?php

$this->dojo()

->requireModule('dojox.data.QueryReadStore?')

?> <?php $this->headScript()->captureStart(); ?> dojo.addOnLoad(function () {

Creating store for filtering select through ajax call. var testStore = new dojox.data.QueryReadStore?({url: '/app/test/ajaxfilteringselectstore'}); dijit.byId('testfilteringSelect').set("store", testStore) Setting value to test filtering select. var val = document.getElementById('testfilteringSelect').value; dijit.byId('testfilteringSelect').setValue(val); dijit.byId('testfilteringSelect').startup();

}); <?php $this->headScript()->captureEnd(); ?> <?php

echo $this->form;

?>

when I set filtering select multiOptions fields with an array of 40 items. It worked fine. But when I used ajax call to set the store of filtering select with 36 items with pageCount as 10. It breaks after displaying only 29 items. It shows only More Choices option and Previous Choices option in the last iteration without displaying last 6 items. Clicking on More Choices option is not working after that but we can traverse back with Previous Choices option. I have attached screenshot for reference for all iterations.

I am pasting the array returned by ajax call with 36 items:-

array(36) {

[0]=> array(1) {

name?=> string(4) "abc0"

} [1]=> array(1) {

name?=> string(4) "abc1"

} [2]=> array(1) {

name?=> string(4) "abc2"

} [3]=> array(1) {

name?=> string(4) "abc3"

} [4]=> array(1) {

name?=> string(4) "abc4"

} [5]=> array(1) {

name?=> string(4) "abc5"

} [6]=> array(1) {

name?=> string(4) "abc6"

} [7]=> array(1) {

name?=> string(4) "abc7"

} [8]=> array(1) {

name?=> string(4) "abc8"

} [9]=> array(1) {

name?=> string(4) "abc9"

} [10]=> array(1) {

name?=> string(5) "abc10"

} [11]=> array(1) {

name?=> string(5) "abc11"

} [12]=> array(1) {

name?=> string(5) "abc12"

} [13]=> array(1) {

name?=> string(5) "abc13"

} [14]=> array(1) {

name?=> string(5) "abc14"

} [15]=> array(1) {

name?=> string(5) "abc15"

} [16]=> array(1) {

name?=> string(5) "abc16"

} [17]=> array(1) {

name?=> string(5) "abc17"

} [18]=> array(1) {

name?=> string(5) "abc18"

} [19]=> array(1) {

name?=> string(5) "abc19"

} [20]=> array(1) {

name?=> string(5) "abc20"

} [21]=> array(1) {

name?=> string(5) "abc21"

} [22]=> array(1) {

name?=> string(5) "abc22"

} [23]=> array(1) {

name?=> string(5) "abc23"

} [24]=> array(1) {

name?=> string(5) "abc24"

} [25]=> array(1) {

name?=> string(5) "abc25"

} [26]=> array(1) {

name?=> string(5) "abc26"

} [27]=> array(1) {

name?=> string(5) "abc27"

} [28]=> array(1) {

name?=> string(5) "abc28"

} [29]=> array(1) {

name?=> string(5) "abc29"

} [30]=> array(1) {

name?=> string(5) "abc30"

} [31]=> array(1) {

name?=> string(5) "abc31"

} [32]=> array(1) {

name?=> string(5) "abc32"

} [33]=> array(1) {

name?=> string(5) "abc33"

} [34]=> array(1) {

name?=> string(5) "abc34"

} [35]=> array(1) {

name?=> string(5) "abc35"

}

}

Please feel free to contact me for any queries or any other information required.

Thanks in Advance.

Regards Vish

comment:6 Changed 4 years ago by vish

Re-Opening

comment:7 Changed 4 years ago by bill

The link you gave is to a blog post, not a test case. I see you pasted in a lot of PHP code, but it doesn't seem like the whole test case? Can you reduce the test case to something that runs without PHP? Perhaps modify dijit's existing test_Combobox.html test case.

When you've produced a minimal test case, attach it using the "Attach File" button and then write a comment back here.

Note: See TracTickets for help on using tickets.