jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox Add new item to the combobox source.

This topic contains 0 replies, has 1 voice, and was last updated by  Apeksha Singh 11 years, 4 months ago.

Viewing 1 post (of 1 total)
  • Author
  • Add new item to the combobox source. #31449

    Apeksha Singh
    Participant

    Hi,

    In my project I have a jqxGrid in which one columns contain jqxCombobox with list of items.

    On the click of an item from jqxCombobox dropdownlist named “Add New Item” , I can add new items by using a form that is opened in  jqxwindow.

    I am able to add it properly but the source of  jqxCombobox is not getting updated unless I refreshed the page.

    I am adding my code below please guide me regarding this as soon as possible.

     {
    text: 'Item',
    columntype: 'combobox',
    datafield: 'inventory_item_id',
    createeditor: function (row, column, editor) {
    editor.jqxComboBox({
    source: item,
    selectedIndex: 0,
    dropDownWidth: 160
    });
    $(editor).on('open', function (event) { //changed from change to open event so that no event get fired unless dropdown is open..
    var NewInventoryAdded = window.app.constants.InventoryItemAdded;
    console.log("InVoice InventoryItemAdded: ", NewInventoryAdded);
    if ((NewInventoryAdded !== null) && (NewInventoryAdded !== undefined)) {
    //$(editor).jqxComboBox('addItem', { label: NewInventoryAdded.name } );
    console.log("InVoice InventoryItemAdded: ", NewInventoryAdded);
    var itemsItem = {
    html: "",
    label: NewInventoryAdded.name,
    value: NewInventoryAdded.id
    };
    item.push(itemsItem);
    //key value creation...
    var key = NewInventoryAdded.id;
    var value = NewInventoryAdded.name;
    //object creation....
    inventoryItemsObject[key] = value;
    console.log("InVoice inventoryItemsObject: ", inventoryItemsObject, item);
    NewInventoryAdded = null;
    window.app.constants.InventoryItemAdded = NewInventoryAdded;
    }
    $(editor).on('select', function (event) {
    var args = event.args;
    if (args) {
    var item = args.item;
    if (item !== null) {
    var item_id = null;
    item_id = item.originalItem.value;
    //cod eto fetch and populate the row for selected inventory item...
    if ((item_id !== undefined) && (item_id !== -1)) {
    fetch_row_item_data(selected_grid_row, item_id);
    }
    //code to open new inventory item popup on selecting add new item list item
    else if ((event.args.item !== undefined) && (item_id === -1)) {
    if (self.options.router.routes[Backbone.history.fragment]) {
    console.log("in Add New Item........");
    var current_hash = Backbone.history.fragment;
    self.options.router.add_inventory_popup_from = 0; //desined in router as used in addinventory popoup view. to show popup window properly...
    self.goToThisRoute('addinventory');
    self.options.router.vent.trigger('goToRouteOnClose', 'test');
    //to prevent firing of multiple events..
    self.options.router.vent.unbind('goToRouteOnClose');
    lock_grid_event_firing = 0;
    } else {
    console.log("in Add New Item........");
    var current_hash = Backbone.history.fragment;
    //self.goToThisRoute('test');//to go on same route again
    self.options.router.add_inventory_popup_from = 0; //desined in router as used in addinventory popoup view. to show popup window properly...
    self.goToThisRoute('addinventory');
    self.options.router.vent.trigger('goToRouteOnClose', 'test');
    //to prevent firing of multiple events..
    self.options.router.vent.unbind('goToRouteOnClose');
    lock_grid_event_firing = 0;
    }
    lock_grid_event_firing = 1;
    return;
    }
    }
    }
    });
    });
    },
    width: '13%'
    },

    Thanks & Regards,

    Apeksha

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.