Forums

Forums / Developing Portals / Placeholder in picklist

Placeholder in picklist

2 posts, 1 answered
  1. mani varma
    mani varma avatar
    8 posts
    Registered:
    21 Jul 2020
    21 Jul 2020
    Link to this post
    Is there any way we could include placeholder in a picklist widget, because it is not working even if i try editing cshtml template or even try to add html attribute (placeholder="choose option") to the html
  2. Josh
    Josh avatar
    47 posts
    Registered:
    01 Jun 2018
    Answered
    21 Jul 2020 in reply to mani varma
    Link to this post
    Hello Mani,

    Unfortunately, this behaviour cannot be accomplished via a configuration setting at the moment. What we can do is add some custom JavaScript that will add a placeholder value upon the successful load of the form. Please see the code sample attached below that will add a placeholder to a TPC Picklist that says: “Please select an option”. You can add this to the page using a TPC JavaScript widget.

    /**
     * This sample will add default value placeholder text to a TPC Picklist. 
     */
    
    $(document).on("tpc:ready", function(){
    
        //Name of Picklist
        var picklistName = "accountcategorycode";
    
        //Set Text to Placeholder Value
        tpc.forms[0][picklistName].get_kendoInput().text("Please select an option.");
    });
    

    Cheers,

    Josh
     
2 posts, 1 answered