Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Set combobox default value while add new row
posted

Hi,

I have a combobox and I want to set to default value while adding a new row. Adding new row is also  custom functionality.

Thanks

Ravi

  • 380
    Offline posted

    Hello Indra,

    I have been looking into your question and there are two approaches to have a default value in the given cells that you want when adding a new row according to your custom logic.

    What I suggest as a first approach is to use the DefaultValue property of ColumnSettings when initializing the Updating feature of the igGrid. As in the given DefaultValue property you enter the value according to the datatype of the column, in this way when adding a new row, you will have initialized default values in the given cells of the given column.

    .Features(features =>
             {
                 features.Updating()
                 .ColumnSettings(settings =>
                 {
    settings.ColumnSetting().ColumnKey("Name").DefaultValue("John");
    settings.ColumnSetting().ColumnKey("Country").DefaultValue("USA").EditorType(ColumnEditorType.Combo).ComboEditorOptions(options =>
                 {
                     options.DataSource(Model.Countries);
                     options.TextKey("Value");
                     options.ValueKey("Value");
                 });
                 });
             })

    As a second approach, you can use the EditRowStarted event from GridUpdatingClientEvents by adding it to the initialization of the updating feature with AddClientEvent. After that you will enter a function name and in a script tag you will create the function itself. In the given function, you will check whether you are currently adding a row and if so, you will take the given editor according to the column key and set its value on this editor, as for the igCombo this is done with an index option and setting a value.

    .Features(features =>
    {
    features.Updating().AddClientEvent(GridUpdatingClientEvents.EditRowStarted, "editRowStarted");
    }

    <script>
        function editRowStarted(event, ui) {
            if (ui.rowAdding) {
                var editorCountry = $(ui.owner.editorForKey("Country"));
                editorCountry.igCombo("index", 1);
                var editorName = $(ui.owner.editorForKey("Name"));
                editorName.igTextEditor("value", "John");
            }
        }
    </script>

    The described scenario could be observed here:

     

    In addition, I have prepared small sample illustrating this behavior which could be found attached here. Please test it on your side and let me know how it behaves.

    3362.igGridComboBoxDefaultValue.zip

    If you require any further assistance on the matter, please let me know.

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics

  • 0
    Offline posted

    Tower Defense Games - strategy game. Fantasy game. Real-time strategy.

    Tower defense game - strategy game
    Play the classic Tower Defense game in the world of Slavic mythologists. Defeat three unique Bosses and save the ancient world.
    If you are a lover of real-time strategy genre, then Tower Defense - strategy game is definitely for you.

    The action takes place in the light of the three moons, on the holy land, guarded by the ancient gods. The darkness that originated in the wormholes multiplied, strengthened, and began to attack the holy lands.
    The capital has already been destroyed, but there is still a chance of victory. Reflect enemy attacks and rebuild the city. Only YOU can stop evil in the decisive battle.
    Reflects attacks in forests, swamps and ancient cities, in the snowy north and in the magical world. Do not let the enemy destroy the main sanctuary of the Slavs! Upgrade defense towers, apply spells and use heroes, set traps, call assistants, you have the power to win, the main thing is to use it correctly!
    Rebuild the destroyed city and you will gain an advantage over your enemies. Kick your hero in battle royale and use all his power on the battlefield.


    Specifications:

    * 70 levels.
    * Orcs, elves, witches, spirits, trolls, zombies, giants and many enemies.
    * Hero - person whose Spirit can be summoned at any time.
    * Boss at the end of the level.
    * 3 super bosses at the end of each location.
    * A large number of cards.
    * Stunning locations - forest, swamp, old city, winter north and a magical world.
    * Hero level up
    * Restore destroyed city.

    In Tower Defense Games - intense game you can free the world from evil and perhaps you will be worshiped as a god by the descendants of a great civilization!

  • 0
    Offline posted


    I am glad that you find my suggestion helpful.

    Thank you for using Infragistics components.  planet fitness guest pass

  • 0
    Offline posted

    Once you’ve narrowed down your choices, it’s time to start the shopping process. If you’re looking for a new motorcycle, then you’ll likely want to visit a few local dealerships. Here, you’ll be able to get a good look at the different models and speak with knowledgeable sales associates. If you’re in the market for a used bike, then there are plenty of classifieds, online retailers, and local shops that you can explore. https://justbmxbikes.com/best-29-inch-bmx-bikes/

  • 0
    Offline posted

    Thanks for all the answers, I also would like to share a very useful website super betting