javascript - Populating a FilteringSelect datastore from an onChange event - Stack Overflow

I'm trying to bind an onChange event of one FilteringSelect to populate another FilteringSelect.

I'm trying to bind an onChange event of one FilteringSelect to populate another FilteringSelect.

// View
dojo.addOnLoad(function () {
    dojo.connect(dijit.byId('filterselect1'), 'onChange', function () {
        dijit.byId('filterselect2').store = new dojo.data.ItemFileReadStore(
            { url: "/test/autoplete/id/" + dijit.byId("filterselect1").value }
        );
    });
});

The JSON is generated from what I can tell correctly from a Zend Action Controller using a autoCompleteDojo helper.

// Action Controller
public function autopleteAction()
{
    $id = $this->getRequest()->getParam('id');
    $select = $this->_table->select()
                           ->from($this->_table, array('id','description'))
                           ->where('id=?',$id);

    $data = new Zend_Dojo_Data('id', $this->_table->fetchAll($select)->toArray(), 'description');

    $this->_helper->autoCompleteDojo($data);
}

I receive the JSON from the remote datastore correctly, but it does not populate the second FilteringSelect. Is there something else I need to do to push the JSON onto the FilteringSelect?

I'm trying to bind an onChange event of one FilteringSelect to populate another FilteringSelect.

// View
dojo.addOnLoad(function () {
    dojo.connect(dijit.byId('filterselect1'), 'onChange', function () {
        dijit.byId('filterselect2').store = new dojo.data.ItemFileReadStore(
            { url: "/test/autoplete/id/" + dijit.byId("filterselect1").value }
        );
    });
});

The JSON is generated from what I can tell correctly from a Zend Action Controller using a autoCompleteDojo helper.

// Action Controller
public function autopleteAction()
{
    $id = $this->getRequest()->getParam('id');
    $select = $this->_table->select()
                           ->from($this->_table, array('id','description'))
                           ->where('id=?',$id);

    $data = new Zend_Dojo_Data('id', $this->_table->fetchAll($select)->toArray(), 'description');

    $this->_helper->autoCompleteDojo($data);
}

I receive the JSON from the remote datastore correctly, but it does not populate the second FilteringSelect. Is there something else I need to do to push the JSON onto the FilteringSelect?

Share Improve this question edited Sep 16, 2016 at 12:50 slava 1,9156 gold badges28 silver badges33 bronze badges asked Apr 15, 2009 at 20:22 ErikErik 3701 gold badge2 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I couldn't believe this was causing the problem, but the whole issue boiled down to the fact that it appears that a dojo ItemFileReadStore REQUIRES the label property of the JSON to be "name". In the end this is all that it required to wire them together.

dojo.addOnLoad(function () {

    dijit.byId('filtering_select_2').store = new dojo.data.ItemFileReadStore({url: '/site/url'});

    dojo.connect(dijit.byId('filtering_select_1'), 'onChange', function (val) {
        dijit.byId('filtering_select_2').query.property_1 = val || "*";
    });
});

UPDATE: The property within Zend form has been fixed as of ZF 1.8.4

Try console.log() in the event to see if it is launched. Changing the store should work, however for other widgets like grid you have also to call refreshing methods.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742320739a4421756.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信