Announcement

Collapse
No announcement yet.

How to customize the search.js?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to customize the search.js?

    I want to customize espocrm/client/src/views/record/search.js file.

    Can anyone help me with how to do this?

    Research:
    1. We have espocrm/client/src/views/list.js file which will define the searchView as views/record/search.
    2. Similarly, the recordView: 'views/record/list' is defined in theespocrm/client/src/views/list.js.
      1. I can define the custom: views/record/list in espocrm/custom/Espo/Custom/Resources/metadata/clientDefs/Lead.json.
    Can I do something like this for the search.js file also ?
    yuri
    Last edited by Ananya K; 05-12-2021, 11:27 AM.

  • #2
    Not sure if telecastg post tutorial related to the search function but there is quite a few resources that may or may not help you. Check the end of this link where I add most of telecastg's guide thread.

    https://github.com/o-data/EspoCRM-Le...nd-Design/wiki

    Comment


  • #3
    Perhaps this post can help you understanding Espo program structure for future reference

    https://forum.espocrm.com/forum/deve...hing#post61633

    Comment


    • #4
      Hey,

      I want to clean up the advanced filter values when we refresh the page. Otherwise, we need to clean up the text box value and then enter the next value.

      So I want to add a button next to the Reset Button its a refresh which will clean up all the value in the advanced search field text box.

      To do this I need to edit the search.js

      Feature Request Pull Request: https://github.com/espocrm/espocrm/pull/1996

      yuri
      Attached Files
      Last edited by Ananya K; 05-13-2021, 07:17 PM.

      Comment


      • #5
        Hi,

        Here's how you can incorporate your custom search.js script for the Lead entity in a "upgrade safe" way while your pull request is approved:

        Define your own search.js class in the custom namespace. for example:
        client/custom/src/views/record/search.js
        Code:
        define('custom:views/record/search', 'views/record/search', function (Dep) {
        
            return Dep.extend({
        
        WRITE HERE ALL YOUR CUSTOM SEARCH CODE
        
            });
        });
        Define a custom header list view class that will invoke the custom search instead of the core class, for example:
        client/custom/src/views/header/list.js
        Code:
        define('custom:views/header/list', 'views/list', function (Dep) {
        
            return Dep.extend({
        
                searchView: 'custom:views/record/search'
        
            )};
        
        });
        Define a custom clientDefs metadata script to set the custom header list view as the "list view" for your target Entity ("Lead") class:
        custom/Espo/Custom/Resources/metadata/clientDefs/Lead.json
        Code:
        {
            "views": {
                "list": "custom:views/header/list"
            }
        
        }

        Clear cache and rebuild.

        Please post your custom implementation of search.js here when you are done, so other users will be able to benefit from your development too

        Comment


        • #6
          Hey telecastg

          This works cool. Thank you soo much for the help.

          Here are my custom search.js and search.tpl files.
          Attached Files

          Comment


          • telecastg
            telecastg commented
            Editing a comment
            Thanks for posting your solution, I'm sure that many other forum participants will benefit from your contribution.

        • #7
          Hi all, quick info for anyone following this thread. Ananya made a Pull Request for this I believe, too bad it is still Open though: https://github.com/espocrm/espocrm/pull/1996

          Comment

          Working...
          X