Here I have a html ready-made product table that was formed by the catalog.section bitrix component. It’s impossible to do standard Bitrix tools, since the price is not standard, the mark-up depends on the brand, the client and the product. And this markup is not described in the Bitrix table.

The question is, is it possible to write an html table in json and how? To sort through the Ajax on the server Zazza/Kenju , jqgrid ? Which is better Why exactly on the server, because if you perform the sorting on the client, the sorting time is directly proportional to the work of the client's processor. If the client has a weak processor, the sorting will be very slow.

    1 answer 1

    Doing this correctly is not writing html in JSON, but preparing a new template for catalog.section .

    In the template, you immediately sort-pack the whole thing into an array, which is then json_encode .

    To invoke a component, create a separate file in which you load only /bitrix/modules/main/include/prolog_before.php in order not to load the main template.

    Well, do not forget about UTF-8 , which is needed for JSON and json_encode

    • “In the template, you immediately sort-pack the whole thing into an array, which you then json_encode.” Please specify ..... I understand that it is necessary to sort in javascript, as in my case, write down the price, sorted index and brand in json ? via ajax call a component. So? Something seems to mean that you have something else in mind .... - NNN
    • Php template - i.e. server side sorting For the same jqgrid this will definitely have to be done if you want speed. - Andrewus
    • @AndrewNilolsky, thank you, but I do not understand .... That is, if I want to sort either by code, or by description, or by company, then sorting goes by all fields. If I want to sort by either price or delivery time either by cash - then sorting goes inside the merged block. I store the data in json (product id, number of descendants, descendant id, company, code, description, cash, delivery time, price). Send json to the ajax server with a request. We return the finished html table sorted. Question how to sort on the server? prntscr.com/980y42 - NNN