Skip to main content

Search

Adding Auto-complete to Lookup Fields - search/select dropdowns

Comments

1 comment

  • ArdeviaForum

    Original Post by Taras Lozynskyy (Imported from Ardevia Forum)

    Hi .
    Please look at the following article.
    You need you add Script Editor Web Part, and insert your fields template rendering script in it, like this one:

    Code:

    <script type="text/javascript">
    function MyFieldControl(ctx) {
      // Instead of hardcoding the field value, we can fetch it from the context
    var fieldInternalName = ctx.CurrentFieldSchema.Name;
    var controlId = fieldInternalName + "_control";
    
      // Initialization of the field: here I'm attaching onchange event to my control,
      // so that whenever text is changed, FormContext.updateControlValue is executed.
      ctx.FormContext.registerInitCallback(fieldInternalName, function () {
    
          $addHandler($get(controlId), "change", function(e) {
              ctx.FormContext.updateControlValue(fieldInternalName, $get(controlId).value);
          });
    
      });
    
      return '<input type="text" id="'+controlId+ '" name="'+controlId+'" class="my-input"  />';
    }
        // here is template rendering registration for Title filed
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
      Templates: {
        Fields: {
          'Title': {
    EditForm: MyFieldControl,
    NewForm: MyFieldControl
          }
        }
     }
      });
    </script>
    
    0

Please sign in to leave a comment.