Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load info after save and select option #1437

Open
persianlionn opened this issue May 6, 2024 · 3 comments
Open

Load info after save and select option #1437

persianlionn opened this issue May 6, 2024 · 3 comments

Comments

@persianlionn
Copy link

Hi
I am using jsgrid in wordpress. I have three problems.
1- The saving is done well, but after clicking on the save icon, the information is not loaded and the page must be refreshed.
2- I have a select tag named type that I don't know how to show it as selected. It means that what is stored in the database will be displayed in this selector.
3- The select tag does not display anything by default. Although I have used selectedIndex. It is clear in the picture below.
scrnli_5_6_2024_10-06-36 AM

<script>
    jQuery(document).ready(function ($) {
        var products = [
            
            ID); ?>
            {
                "ID": "ID ?>",
                "ProductName": "get_name(); ?>",
                "Price": "get_regular_price();?>",
                "Discount": "get_sale_price(); ?>",
            },
            
        ];
        var type = [{
            Id: id ?>,
            Name: "name ?>"
        },];
        $("#jsGrid").jsGrid({
            width: "100%",
            height: "400px",
            inserting: false,
            editing: true,
            sorting: true,
            paging: true,
            data: products,
            fields: [
                {
                    title: "",
                    name: "ID",
                    type: "number",
                    width: 80,
                    validate: "required",
                    sorter: "number",
                    align: "center",
                    readOnly: true
                },
                {
                    title: "",
                    name: "ProductName",
                    type: "text",
                    width: 400,
                    validate: "required"
                },
                {
                    title: "",
                    name: "Price",
                    type: "text",
                    width: 150,
                    validate: "required",
                    align: "center",
                },
                {
                    title: "",
                    name: "Type",
                    type: "select",
                    items: type,
                    width: 150,
                    valueField: "Id",
                    textField: "Name",
                    selectedIndex: 0,
                    valueType: "number|string",
                    validate: "required",
                },
                {
                    title: "",
                    name: "Discount",
                    type: "text",
                    width: 80,
                    validate: "required",
                    align: "center",
                },
                {type: 'control', deleteButton: false,}
            ],
            controller: {
                loadData: function (filter) {
                    return $.ajax({
                        type: "GET",
                        dataType: "json",
                        url: "",
                        data: filter,
                    });
                },

                //insertItem: function (item) {
                //    return $.ajax({
                //        type: "POST",
                //        dataType: "json",
                //        url: "//",
                //        data: item
                //    });
                //},

                updateItem: function (item) {
                    return $.ajax({
                        type: "POST",
                        url: "",
                        cache: false,
                        data: {
                            action: 'save_product_info',
                            ID: item['ID'],
                            ProductName: item['ProductName'],
                            Price: item['Price'],
                            Discount: item['Discount'],
                            Type: item['Type'],
                        },
                    });
                },
            }
        });
    });
</script>
@persianlionn
Copy link
Author

Is anybody here?🤔

@bharatdarji
Copy link

Did you get any solution?
We are also facing the same issue.

@persianlionn
Copy link
Author

Did you get any solution? We are also facing the same issue.

No i didn't

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants