首页 \ 问答 \ Redis设置了操作(Redis set operations)

Redis设置了操作(Redis set operations)

Redis集合操作:

SADD key1“value1包含key1”

SADD key1“value2包含key1”

SADD key1“value3包含key1”

SMEMBERS结果:1)“value2包含key1”2)“value3包含key1”3)“value1包含key1”

SREM key1“value2包含key1” - >它的工作原理

现在我想从set中删除“value2 contains key1”,而不传递整个值,例如“value2 contains key1”。 只想发送“value2”

SREM key1“value2”

有没有办法做到这一点? 还是其他方法?


Redis Set Operation:

SADD key1 "value1 containing key1"

SADD key1 "value2 containing key1"

SADD key1 "value3 containing key1"

SMEMBERS Result : 1) "value2 containing key1" 2) "value3 containing key1" 3) "value1 containing key1"

SREM key1 "value2 containing key1" --> it works

Now i want to delete "value2 containing key1" from set, without passing whole value e.g. "value2 containing key1". Want to send only "value2"

SREM key1 "value2"

is there any way to do this ? Or any other method?


原文:https://stackoverflow.com/questions/16018766
更新时间:2022-12-08 07:12

最满意答案

将您的LinkFormatter函数LinkFormatter $(document).ready(function ()

<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery.min.js"></script>
    <script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
     function LinkFormatter(value, row, index) {
                 return "<a href='/details/"+row.id+"'>"+value+"</a>";
                }
    
        $(document).ready(function () {
            //Sample Json data
            var jsondata = [
                {
                    "id": "1",
                    "Name": "Name1",
                    "Address": "Address1"
                },
                {
                    "id": "2",
                    "Name": "Name2",
                    "Address": "Address2"
                },
                {
                    "id": "3",
                    "Name": "Name3",
                    "Address": "Address3"
                }];

            $('#table').bootstrapTable({
                //Assigning data to table
                data: jsondata
            });
  
           
        });
    </script>
</head>
<body>
 
   
    <form id="form1" runat="server">
        <table id="table">
            <thead>
                <tr>
                    <th data-field="id">ID</th>
                    <th data-field="Name" data-formatter="LinkFormatter">Name</th>
                    <th data-field="Address">Address</th>
                </tr>
            </thead>
        </table>
    </form>
    
   
</body>
</html>


Move your LinkFormatter function outside $(document).ready(function ()

<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery.min.js"></script>
    <script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
     function LinkFormatter(value, row, index) {
                 return "<a href='/details/"+row.id+"'>"+value+"</a>";
                }
    
        $(document).ready(function () {
            //Sample Json data
            var jsondata = [
                {
                    "id": "1",
                    "Name": "Name1",
                    "Address": "Address1"
                },
                {
                    "id": "2",
                    "Name": "Name2",
                    "Address": "Address2"
                },
                {
                    "id": "3",
                    "Name": "Name3",
                    "Address": "Address3"
                }];

            $('#table').bootstrapTable({
                //Assigning data to table
                data: jsondata
            });
  
           
        });
    </script>
</head>
<body>
 
   
    <form id="form1" runat="server">
        <table id="table">
            <thead>
                <tr>
                    <th data-field="id">ID</th>
                    <th data-field="Name" data-formatter="LinkFormatter">Name</th>
                    <th data-field="Address">Address</th>
                </tr>
            </thead>
        </table>
    </form>
    
   
</body>
</html>

相关问答

更多
  • 尝试为该特定列添加style参数,如下所示: grid.Column(header: "Edit", format: (item) => { var link = Html.ActionLink("Edit", "Edit", new { id = item.Id }); return link; }, style: "btn btn-default") Try adding the style argument for that specific column like so: grid ...
  • 将您的LinkFormatter函数LinkFormatter $(document).ready(function ()