StataSave Error when reload

StataSave Error when reload

Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

ERROR : Uncaught TypeError: Cannot read property 'prop' of undefined
hello, except the status of my multiselec filter and then reload them, but when I reload but it gives me this error, can you help me please?
Here

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @Massimo74 ,

    The error is coming from the multipleSelect plugin - so you need to look there. It's probably because your code isn't checking that something has been set before trying to reselect.

    Cheers,

    Colin

  • Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

    sorry but as a sequence together first stateLoadParams or initComplete could be that it doesn't find the multiselect as it is in initcomplete?

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Yep, that would do it. So you could store the values in the stateLoadParams, and apply them to the multipleSelect plugin in the initComplete.

  • kthorngrenkthorngren Posts: 21,147Questions: 26Answers: 4,918

    Try placing a console.log statement in stateLoadParams to see what data contains and you will find that on initial load it doesn't contain the properties shr_Position and shr_Office. For example:
    http://live.datatables.net/hamifadi/1/edit

    You will need to check (using if) for the existence of those properties. If they exist you can use the code the ...multipleSelect('setSelects'... code.

    Kevin

  • Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

    when active on stateSaveParams:
    data.shr_Position = $('#shrMulPosition').multipleSelect('getSelects');
    the plugin Multiselect go Error (NOT WORK)

    I believe that the only system is to manually save via an onclick event and reload the saved parameters via onAfterCreate, but how do I save them and read them manually ??
    See Here

  • kthorngrenkthorngren Posts: 21,147Questions: 26Answers: 4,918

    As you noted, it seems the problem is that the state load runs before initComplete. As Colin mentioned you can get the values in stateLoadParams and save to global variables, for example. Then in initComplete use those variables to set the selects.

    Kevin

  • Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

    thanks kevin, I understood the problem but in fact my question was exactly how I saved and I read the values ​​?? do you have an example?

  • kthorngrenkthorngren Posts: 21,147Questions: 26Answers: 4,918

    From a state save and load perspective I think what you are doing is fine. As far as the Multi Select API it looks right according the the quick look I took at the docs. You will need to refer to those for specifics regarding that plugin.

    The problem is you are trying to set the multi select with ...multipleSelect('setSelects'... before it has been initialized in the stateLoadParams function. Instead of setting it there just save the two values to global variables that you can access in initComplete and use the ...multipleSelect('setSelects'... after you init the multiselect.

    Kevin

This discussion has been closed.