Git Product home page Git Product logo

Comments (1)

halftrainedharry avatar halftrainedharry commented on July 28, 2024

I don't think you can make this work with renderSwitchStatusOptions. The problem is, that the render information (what picture to show etc.) is generated in PHP and stored in an extra field with the ending _ro (e.g. visible_on_page_ro). When you click "Save" in the update-window this information is lost.

You'd have to make an AJAX-call to get the current render information.


The easiest solution is probably to code a custom renderer with hard-coded render options.

  • Create a file grid.config.inc.php in core/components/somepackagename/migxconfigs/grid.
  • Add code for your custom renderer and handler function to this file. Something like this may work:
<?php
$my_img = '<a href="#" ><img class="controlBtn {3} {4} {5}" src="'.$base_url.'{0}" alt="{1}" title="{2}"></a>';
$renderer['this.myRenderSwitchStatusOptions'] = "
myRenderSwitchStatusOptions : function(val, md, rec, row, col, s) {
    var column = this.getColumnModel().getColumnAt(col);
    var renderImage, altText, handler, classname;
    if (val == '1'){
        renderImage = 'assets/img/icons/yes.png';
        altText = 'yes';
    } else {
        renderImage = 'assets/img/icons/no.png';
        altText = 'no';
    }
    handler = 'this.myHandleColumnSwitch';
    classname = '';
    return String.format('{$my_img}', renderImage, altText, altText, classname, handler, column.dataIndex);
}
";

$gridfunctions['this.myHandleColumnSwitch'] = "
myHandleColumnSwitch: function(n,e,col) {   
    this.selected_records = this.getSelectionModel().getSelections();
    var old_val = this.selected_records[0].get(col);
    var new_val;
    if (old_val == '1'){
        new_val = '';
    } else {
        new_val = '1';
    }
    this.updateSelected({dataIndex: col}, new_val);
}	
";
?>
  • In your config in the tab "MIGXdb-Settings" set the field "Package" to somepackagename.
  • In the tab "Columns" select your custom renderer ("this.myRenderSwitchStatusOptions") from the list.
  • In the tab "Handlers" check the checkbox for the custom handler "this.myHandleColumnSwitch".

from migx.

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.