GithubHelp home page GithubHelp logo

Initialize Value about combo-tree HOT 13 CLOSED

erhanfirat avatar erhanfirat commented on June 15, 2024
Initialize Value

from combo-tree.

Comments (13)

crazy4chrissi avatar crazy4chrissi commented on June 15, 2024

I know it may be a little late for you, but I implemented this in my fork: https://github.com/crazy4chrissi/combo-tree

from combo-tree.

JayaswaminathanS avatar JayaswaminathanS commented on June 15, 2024

Hi,
I Want to change the Json value dynamically.But it displayed old value only. Json value not updated dynamically.

from combo-tree.

crazy4chrissi avatar crazy4chrissi commented on June 15, 2024

This issue and the whole JSON is about the initial data of the tree. "Initial" implies it is not dynamical ;)

So what you want to do is select a value using JS? By id? Of course you can just trigger click() on the respective element to select/unselect an item. Sure, a predefined function for that would be handy.

from combo-tree.

JayaswaminathanS avatar JayaswaminathanS commented on June 15, 2024

Yes, I am done using id. Function invoke ajax call and pass data comboTree.But data not rendered. Initial data only displayed.dynamic data not worked.

from combo-tree.

blacktek avatar blacktek commented on June 15, 2024

I know it may be a little late for you, but I implemented this in my fork: https://github.com/crazy4chrissi/combo-tree

would it be possible to add an extra attribute selected=true|false to each json "leaf"? this way the plugin can set initial selection. I think that without this is not so much usefull

from combo-tree.

crazy4chrissi avatar crazy4chrissi commented on June 15, 2024

@blacktek What is the difference between what you propose and the preselect attribute I added in my fork? Just add it to any leaf you want initially selected.

from combo-tree.

blacktek avatar blacktek commented on June 15, 2024

@blacktek What is the difference between what you propose and the preselect attribute I added in my fork? Just add it to any leaf you want initially selected.

sorry I didn't notice it; I manually edited the source to add this functionality :) I added a "disabled" property too in order to have nodes that are not selectable. Thank you!

from combo-tree.

blacktek avatar blacktek commented on June 15, 2024

one thing I made differently was adding at line 116 this code:

this._selectedItem = {
id: sourceItem.id,
title: sourceItem.title
};

		this._selectedItems.push(this._selectedItem);	

I didn't do the trigger('click') in the constructor; the proposed solution should be more cpu effective.

from combo-tree.

ARr0w avatar ARr0w commented on June 15, 2024

Guys, i did make changes and got setting value to work. Just add these functions along with other prototype functions and use it.

`

// Set Values
// *****************************
ComboTree.prototype.setValues = function (data) {
    if (data !== null &&
        data !== undefined &&
        typeof data !== "string" &&
        typeof data !== "number" &&
        typeof data !== "function") {

        if (data.length > 0) {
            for (var k = 0; k < data.length; k++) {
                this.manageValues(data[k]);
            }
        }
    }
};

ComboTree.prototype.manageValues = function(sourceItem) {
    var isThereSubs = sourceItem.hasOwnProperty("subs");
    if (isThereSubs) {
        var li = $('#' + this.comboTreeId + 'Wrapper li.ComboTreeItemParent');
        li.find('span.comboTreeItemTitle[data-id=' + sourceItem.id + ']').trigger("click");
        this.manageValues(sourceItem.subs);
    } else {
        $('#' + this.comboTreeId + 'Wrapper span.comboTreeItemTitle[data-id=' + sourceItem.id + ']').trigger("click");
    }
};

`
Hope it helps. Enjoy! :)

Usage:
comboTree.setValues(objArr);

from combo-tree.

erhanfirat avatar erhanfirat commented on June 15, 2024

Hi all,

You can use setSelection method of new version.

Thanks...

from combo-tree.

blacktek avatar blacktek commented on June 15, 2024

from combo-tree.

karuguvel avatar karuguvel commented on June 15, 2024

Hi all,
I am new to combo tree. how do i implement setSelection method
Could you please help on this

from combo-tree.

techiesalman avatar techiesalman commented on June 15, 2024

Uncaught TypeError: setSelection is not a function.

This error is coming while setting value using setSelection.

from combo-tree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.